iso8601_to_datetime [ WordPress Function ]
iso8601_to_datetime ( $date_string, $timezone = 'user' )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: is_date, is_time, iso8601_timezone_to_offset, is_local_attachment, option_update_filter
Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
Source
<?php
function iso8601_to_datetime($date_string, $timezone = 'user') {
$timezone = strtolower($timezone);
if ($timezone == 'gmt') {
preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
$offset = iso8601_timezone_to_offset($date_bits[7]);
} else { // we don't have a timezone, so we assume user local timezone (not server's!)
$offset = 3600 * get_option('gmt_offset');
}
$timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
$timestamp -= $offset;
return gmdate('Y-m-d H:i:s', $timestamp);
} else if ($timezone == 'user') {
return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
}
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/iso8601 to datetime « WordPress Codex
Description. Converts an iso8601 date to MySQL DATETIME format used by post_date[_gmt]. Usage. <?php iso8601_to_datetime( $date_string, $timezone ) ?> ...
codex.wordpress.org - Docs for page formatting.php
return: The date and time in MySQL DateTime format - Y-m-d H:i:s. since: 1.5.0. string iso8601_to_datetime (string $date_string, [string $timezone = 'user']) ...
phpdoc.wordpress.org - iso8601_to_datetime | A HitchHackers guide through WordPress
Feb 12, 2011 ... Definition: function iso8601_to_datetime($date_string, $timezone = 'user') {}. Converts an iso8601 date to MySQL DateTime format used by ...
hitchhackerguide.com - iso8601 - How do I convert an ISO 8601 string to a Delphi TDate ...
... settings you wish to use at the time. Function ISO8601ToDateTime(Value: String):TDateTime; var FormatSettings: TFormatSettings; begin ...
stackoverflow.com