Switch language

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




mysql2date [ WordPress Function ]

mysql2date ( $format, $date, $translate = true )
Parameters:
  • (string) $format Format of the date to return.
  • (string) $date Date string to convert.
  • (bool) $translate Whether the return date should be translated. Default is true.
Returns:
  • (string|int) Formatted date string, or Unix timestamp.
Defined at:

Benzer Fonksiyonlar: is_date, translate, _wp_mysql_week


Converts given date string into a different format.

$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.

If $translate is true then the given date and format string will be passed to date_i18n() for translation.

Source


<?php
function mysql2date$format$date$translate true ) {
    if ( empty( 
$date ) )
        return 
false;

    if ( 
'G' == $format )
        return 
strtotime$date ' +0000' );

    
$i strtotime$date );

    if ( 
'U' == $format )
        return 
$i;

    if ( 
$translate )
        return 
date_i18n$format$i );
    else
        return 
date$format$i );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



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