Parse English textual datetimes into Unix timestamps in PHP

Description

The following code shows how to parse English textual datetimes into Unix timestamps.

Example


  //from www.ja  v a 2  s .  c  o  m
<?php
    echo(strtotime("now") . "<br>");
    echo(strtotime("3 October 2005") . "<br>");
    echo(strtotime("+5 hours") . "<br>");
    echo(strtotime("+1 week") . "<br>");
    echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "<br>");
    echo(strtotime("next Monday") . "<br>");
    echo(strtotime("last Sunday"));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone