Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_date_from_gmt [ WordPress Function ]

get_date_from_gmt ( $string, $format = 'Y-m-d H:i:s' )
Parameters:
  • (string) $string The date to be converted.
  • (string) $format The format string for the returned date (default is Y-m-d H:i:s)
Returns:
  • (string) Formatted date relative to the GMT offset.
Defined at:



Converts a GMT date into the correct format for the blog.

Requires and returns in the Y-m-d H:i:s format. Simply adds the value of gmt_offset.Return format can be overridden using the $format parameter

Source


<?php
function get_date_from_gmt($string$format 'Y-m-d H:i:s') {
    
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#'$string$matches);
    
$string_time gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
    
$string_localtime gmdate($format$string_time get_option('gmt_offset')*3600);
    return 
$string_localtime;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics