Probably one of the most useful time/date related functions in PHP is strtotime(). In this lesson I will show you some of the basic uses for this incredibly useful function.
Using the function is quite straightforward as we can pass in a multitude of strings and the function will parse each of them.
For example:
The function returns a Unix timestamp, which we can then operate on further. The output from the above code is:
We can use other functions on the Unix output and turn this into full dates as follows:
I find this function incredibly useful when dealing with date and time database entries.
If you would like to learn more about PHP then enrol in the PHP for Beginners course.