Phpstrtotime converts a daytime date to a timestamp-PHP source code

Source: Internet
Author: User
Tags echo date
Ec (2); * & nbsp; converts a daytime date to a timestamp & nbsp; strtotime (time, now) parameter description & nbsp; time specifies the time string to be parsed. & Nbsp; now is used to calculate the timestamp of the returned value. If this parameter is omitted, the current time is used. & Nbsp; & lt ;? Php & nbsp; echostrtotime (& quot; now & quot;), & quot; script ec (2); script

/*
Converts a daytime date to a timestamp.
Strtotime (time, now) parameter description
Time specifies the time string to be parsed.
Now is used to calculate the timestamp of the returned value. If this parameter is omitted, the current time is used.

Echo strtotime ("now "),"";
Echo strtotime ("10 September 2000 "),"";
Echo strtotime ("+ 1 day "),"";
Echo strtotime ("+ 1 week "),"";
Echo strtotime ("+ 1 week 2 days 4 hours 2 seconds "),"";
Echo strtotime ("next Thursday "),"";
Echo strtotime ("last Monday "),"";
?>

$ Str = 'Not Good ';

// Previous to PHP 5.1.0 you wowould compare with-1, instead of false
If ($ timestamp = strtotime ($ str) === false ){
Echo "The string ($ str) is bogus ";
} Else {
Echo "$ str =". date ('L dS o f y h: I: s A', $ timestamp );
}
?>

Let's look at the strtotime instance.
*/
Echo strtotime ('2014-2-14 '),"
";
Echo date ('Y-m-d', strtotime ('2017-2-14 '));

// Output value

1266076800
2010-02-14

// You should be in strtotime () and you decide what to do. For example

# On 2/8/2010
Date ('m/d/Y', strtotime ('first Day'); #02/01/10
Date ('m/d/Y', strtotime ('Last Day'); #02/28/10
Date ('m/d/Y', strtotime ('Last day next month'); #03/31/10
Date ('m/d/Y', strtotime ('Last day last month'); #01/31/10
Date ('m/d/Y', strtotime ('2017-12 last Day ')); #12/31/09-this doesn't work if you reverse the order of the year and month
Date ('m/d/Y', strtotime ('2017-03 last Day'); #2009/09
Date ('m/d/Y', strtotime ('2017-03'); #2009/09
Date ('m/d/Y', strtotime ('Last day of march 100'); #2009/09
Date ('m/d/Y', strtotime ('Last day of march'); #03/31/10
?>

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.