If you want to change the date and time format in PHP programming language, then keep your close attention in this post as I am going to share about the PHP strtotime function with the example.
The strtotime() function is a built-in function in PHP programming language. This function will change the textual DateTime into a Unix timestamp as per your requirement.
Below is the Syntax of strtotime function in PHP code.
1 | strtotime ($EnglishDateTime, $time_now) |
1 2 3 4 5 6 7 8 9 | <?php echo strtotime("now"), "\n"; echo strtotime("10 September 2000"), "\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"; ?> |
1 2 3 4 5 6 7 | <?php // prints the converted english text in second echo strtotime("next sunday"), "\n"; // prints the above time in date format echo date("Y-m-d", strtotime("next sunday"))."\n"; ?> |
1525564800
2018-05-06
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.