Function Reference/mysql2date
Description
Converts given mySQL date string into a different format.
Usage
<?php $date = mysql2date($format, $date, $translate); ?>
Parameters
- $format
- (string) (required) The requested output format, should be either a PHP date format string, e.g. 'U' for a Unix timestamp, or 'G' for a Unix timestamp assuming that $date is GMT.
- Default: None
- $date
- (string) (required) the input string, this cannot be the raw time-stamp, it has to be converted into the following format first: 'Y-m-d H:i:s' . This is the only way mysql2date() will recognize your date.
- Default: None
- $translate
- (boolean) (optional) If true then the given date and format string will be passed to date_i18n() for translation.
- Default: true
Return Values
- (string|integer)
- Formatted date string, or Unix timestamp.
Examples
Notes
Change Log
Since: 0.71
Source File
mysql2date() is located in wp-includes/functions.php
Related
Formatting Date and Time