PHP strtotime() Function

What is a strtotime Function?

Explanation

The "strtotime()" function is used to parse about any English textual datetime description into a Unix timestamp.

Syntax:


strtotime(time,now)

In the above syntax the "time" is a mandatory field, which specifies the string to parse, "now" is the optional field is a timestamp used to calculate the returned value, if left current time will be taken.

Example :

<?php
echo date('m/d/Y h:i:s', strtotime('next tuesday')); ?>
Result :

05/27/2014 12:00:00

In the above example the strtotime() function is used to return the date of next tuesday.

Note :

PHP (5 >= 5.1.0)

PHP Topics


Ask Questions

Ask Question