Home >Backend Development >PHP Tutorial >UNIX timestamp function strtotime in php

UNIX timestamp function strtotime in php

WBOY
WBOYOriginal
2016-07-25 08:59:361033browse
  1. echo strtotime ("now"), "n";
  2. echo strtotime ("10 September 2000"), "n";
  3. echo strtotime ("+1 day"), "n" ";
  4. echo strtotime ("+1 week"), "n";
  5. echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "n";
  6. echo strtotime ("next Thursday"), "n" ";
  7. echo strtotime ("last Monday"), "n";
  8. ?>
Copy code

Example 2,

  1. $str = 'Not Good';
  2. if (($timestamp = strtotime($str)) === -1) {
  3. echo "The string ($str) is bogus ";
  4. } else {
  5. echo "$str == ".date('l dS of F Y h:i:s A',$timestamp);
  6. }
  7. ?>
Copy code

this The effect is the same as using mktime().

I hope the above introduction and examples will be helpful to everyone. For the usage of php strtotime function, you can also refer to: Detailed introduction to PHP strtotime function Example of usage of strtotime function in PHP Y2K38 vulnerability in strtotime() and mktime() in php 2038 issue php timestamp function strtotime application example Function efficiency of strtotime in php



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn