The strtotime(), strftime(), and gmstrftime() functions in PHP are used to manipulate and format date and time values. These functions allow converting date strings into timestamps, formatting date strings, and working with GMT time respectively.
strtotime() – Converts an English textual datetime description into a Unix timestamp.strftime() – Formats a local time or date based on a given format.gmstrftime() – Formats time as GMT instead of local time.strtotime(string $datetime) parses human-readable date strings.strftime(string $format, int $timestamp) formats local time.gmstrftime(string $format, int $timestamp) formats GMT time.
// Convert a human-readable date into a Unix timestamp
<?php
$date = "next Monday";
$timestamp = strtotime($date);
echo date("Y-m-d", $timestamp);
?>
The string "next Monday" is converted into a Unix timestamp and then formatted into a readable date using date().
// Format current local time using a custom pattern
<?php
$date = time();
echo strftime("%A, %B %d, %Y", $date);
?>
// Format current time using GMT timezone
<?php
$date = time();
echo gmstrftime("%A, %B %d, %Y", $date);
?>
strtotime() for flexible date parsing.gmstrftime() when working with global systems.15th August 2025.