PHP strtotime function unix timestamp _php tips

Source: Internet
Author: User
The now parameter does not work if the time is in absolute times format. If time is in a relative time format, it is provided by now, or the current time is not available if the?? Returns-1 when failed.

<?php
Echo Strtotime ("Now"), "\ n";
Echo Strtotime ("September"), "\ n";
Echo strtotime ("+1 Day"), "\ n";
Echo strtotime ("+1 Week"), "\ n";
Echo strtotime ("+1 Week 2 days 4 hours 2 Seconds"), "\ n";
Echo Strtotime ("next Thursday"), "\ n";
Echo Strtotime ("Last Monday"), "\ n";
? ><?php
$str = ' not good ';
if (($timestamp = Strtotime ($str)) = = = 1) {
echo "The string ($STR) is bogus";
} else {
echo "$str = =". Date (' L DS of F Y h:i:s A ', $timestamp);
}
?>
This effect is the same as using Mktime ().

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.