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


 

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.

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.

Ads