213 of 410 menu

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

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

Example

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

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

Code execution result:

1767128400

Example

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

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

Code execution result:

968529600

Example

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

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

See Also

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