date Format a Unix timestamp &reftitle.description; stringdate stringformat intnulltimestamp&null; Returns a string formatted according to the given format string using the given integer timestamp (Unix timestamp) or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time. Unix timestamps do not handle timezones. Use the DateTimeImmutable class, and its DateTimeInterface::format formatting method to format date/time information with a timezone attached. &reftitle.parameters; format Format accepted by DateTimeInterface::format. date will always generate 000000 as microseconds since it takes an int parameter, whereas DateTimeInterface::format does support microseconds if an object of type DateTimeInterface was created with microseconds. &date.timestamp.description; &reftitle.returnvalues; Returns a formatted date string. &reftitle.errors; &date.timezone.errors.description; &reftitle.changelog; &Version; &Description; 8.0.0 timestamp is nullable now. &reftitle.examples; <function>date</function> examples ]]> You can prevent a recognized character in the format string from being expanded by escaping it with a preceding backslash. If the character with a backslash is already a special sequence, you may need to also escape the backslash. Escaping characters in <function>date</function> ]]> It is possible to use date and mktime together to find dates in the future or the past. <function>date</function> and <function>mktime</function> example ]]> This can be more reliable than simply adding or subtracting the number of seconds in a day or month to a timestamp because of daylight saving time. Some examples of date formatting. Note that you should escape any other characters, as any which currently have a special meaning will produce undesirable results, and other characters may be assigned meaning in future PHP versions. When escaping, be sure to use single quotes to prevent characters like \n from becoming newlines. <function>date</function> Formatting ]]> To format dates in other languages, IntlDateFormatter::format can be used instead of date. &reftitle.notes; To generate a timestamp from a string representation of the date, you may be able to use strtotime. Additionally, some databases have functions to convert their date formats into timestamps (such as MySQL's UNIX_TIMESTAMP function). Timestamp of the start of the request is available in $_SERVER['REQUEST_TIME']. &reftitle.seealso; DateTimeImmutable::__construct DateTimeInterface::format gmdate idate getdate getlastmod mktime IntlDateFormatter::format time Predefined DateTime Constants