The strtotime Function

The strtotime function converts an arbitrary date to timestamp format. The timestamp format is the number of seconds that have passed since 1st January 1970 up to the given moment in time.

Syntax

phpstrtotime(string $datetime, ?int $baseTimestamp = null): int|false

Example

Let's convert the date '2025-12-31' to a timestamp:

php<?php
  echo strtotime('2025-12-31');
?>

Code execution result:

php1767128400

Example

Let's convert the date of 10th September 2000 to a timestamp:

php<?php
  echo strtotime('10 September 2000');
?>

Code execution result:

php968529600

Example

Let's output tomorrow's date (midnight) in timestamp format:

php<?php
  echo strtotime('Tomorrow');
?>

See Also

  • the checkdate function,
    which checks the validity of a date
  • the date function,
    which formats a given date