The date time is converted into a digital string, how to handle

Source: Internet
Author: User
Tags set time
Date and time converted into a digital string
Example: 2007-01-12 19:15:58
Converted into 20070112191558
How can it be turned into this


------Solution--------------------
$s = ' 2007-01-12 19:15:58 ';
echo Date ("Ymdhis", Strtotime ($s));
------Solution--------------------
Time zone setting, first line plus: Date_default_timezone_set (' PRC ');


------Solution--------------------
Date_default_timezone_set (' PRC ');//Set time zone for China

------Solution--------------------

Select Now () +0

------Solution--------------------
$t =str_replace "-", "", $t);
$t =str_replace "", "", $t);
$t =str_replace ":", "" ", $t);
------Solution--------------------
Wuhan Guest Information Technology Co., Ltd. How to: http://topic.csdn.net/u/20120815/21/ee72e021-2db7-4012-9f67-8f77353351bf.html
------Solution--------------------
Date_default_timezone_set (' PRC ');
$s = ' 2007-01-12 19:15:58 ';
echo Date (' Ymdhis ', strtotime ($s));
------Solution--------------------

$s = ' 2007-01-12 19:15:58 ';
Preg_match_all ('/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/', $s, $mat);
$res = "";
for ($i =1; $i <>
$res. = Join ("', $mat [$i]);
}
echo $res;//20070112191558

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.