Share on Google+Share on Google+

PHP strtotime, PHP strtotime Function, strtotime Function, strtotime Function Example

In this section we will learn PHP strtotime function with the help of example code.

PHP strtotime Function

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:

strtotime(time, now)

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:

echo strtotime("now");

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.


Posted on: April 3, 2006 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.