Home Tutorial Php Phpdate PHP strtotime, PHP strtotime Function, strtotime Function, strtotime Function Example

 
 

Share on Google+Share on Google+
PHP strtotime, PHP strtotime Function, strtotime Function, strtotime Function Example
Posted on: April 3, 2006 at 12:00 AM
Advertisement
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:

<?php
echo strtotime("now");
?>

The above output will return the current unix time stamp.

<?php
echo strtotime("10 January 2010");
?>

The above code will return unix time stamp of the date 10 January 2010.

<?php
echo strtotime("+2 hours");
?>

The above code will add 2 hours in current time and then return the unix timestamp.

<?php
echo strtotime("last Sunday");
?>

The above code will return the unix timestamp of last Sunday.

Advertisement

Related Tags for PHP strtotime, PHP strtotime Function, strtotime Function, strtotime Function Example:


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.

Posted on: April 3, 2006

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com