PHP Simple Strtotime () Time manipulation function _php Tutorial

Source: Internet
Author: User
Tags echo date
Strtotime at this time of the Unix timestamp, the need for a friend can be a simple reference, the middle also said the GETDATE function, then can be output seconds and minutes.
The code is as follows Copy Code

First assume a time
$dt = "2010-09-06 11:19:56";
echo "Time:". $dt. "
";
Format this time as a Unix timestamp
$tm = Strtotime ($DT);
echo "Unix timestamp at this time:" $tm. "
";
?>
Instance

return timestamp with Mktime ()
$tm = Mktime (23,56,59,12,20,1999);
echo "December 20, 1999 23:56 59 seconds Unix Timestamp:". $tm;
return timestamp with Strtotime ()
$tm 2= strtotime ("1999-12-20 23:56:59");
echo "
Time stamp obtained with Strtotime at the same time: ". $tm 2;
?>

Two

Set a time (such as time () available with current
$tm = Strtotime ("2006-09-09 10:30:40");
echo "Initialization set time: 2006-09-09-10:30:40
";
Test the output effect with a different format string
echo Date ("Y-m-d h:i:s A", $tm). "
";
echo Date ("Y-m-d h:i:s a", $tm). "
";
echo Date ("Y year m month D Day [l] H point I min s S", $tm). "
";
echo Date ("F,d,y l", $tm). "
";
echo Date ("Y-m-d h:i:s", $tm). "
";
echo Date ("Y-m-d h:i:s", $tm). "
";
echo Date ("Time zone: T, Difference from GMT: O Hours", $tm). "
";
Output details
?>

Get more information about this time
$arr = getdate ($TM);
Output details
echo "seconds:". $arr ["Seconds"]. "
";
echo "Points:". $arr ["Minutes"]. "
";
echo "When:". $arr ["hours"]. "
";
echo "Day:". $arr ["Mday"]. "
";
echo "Month:". $arr ["Mon"]. " /". $arr [" Month "]."
";
echo "Years:". $arr ["Year"]. "
";
echo "Week:". $arr ["Wday"]. " /". $arr [" Weekday "]."
";
echo "The date is the first of the year". $arr ["Yday"]. " Days
";
?>

http://www.bkjia.com/PHPjc/631321.html www.bkjia.com true http://www.bkjia.com/PHPjc/631321.html techarticle Strtotime at this time of the Unix timestamp, the need for a friend can be a simple reference, the middle also said the GETDATE function, then can be output seconds and minutes. Code to copy the code below? PHP//First ...

  • Related Article

    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.