In this section we will learn strtotime with the help of example code.
About strtotime function:
The strtotime() is used to convert English textual description into a Unix timestamp. The strtotime() function is very handy to convert the text description of time into unix timestamp.
Syntax of strtotime function:
Where time is the required parameter, which is the English textual description of the time. While now is optional parameter, which is the timestamp to be used for calculating the return value. If now parameter is not specified the current time is used to calculate the return value.
Here is the examples of strtotime() function:
The above output will return the current unix time stamp.
echo strtotime("10 January 2010");
The above code will return unix time stamp of the date 10 January 2010.
echo strtotime("+2 hours");
The above code will add 2 hours in current time and then return the unix timestamp.
echo strtotime("last Sunday");
The above code will return the unix timestamp of last Sunday.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.