Is there any way to display the Today's date outside any loop/post using WordPress date/time function instead of using the PHP date()
function?
I'm using the PHP date()
function but it does not translate the date (month/day names) in the local languages, so it is not possible to translate it without changing the PHP code and setting the locale etc.
Add a comment
|
1 Answer
Use date_i18n()
from wp-includes/functions.php
.
/**
* Retrieve the date in localized format, based on timestamp.
*
* If the locale specifies the locale month and weekday, then the locale will
* take over the format for the date. If it isn't, then the date format string
* will be used instead.
*
* @since 0.71
*
* @param string $dateformatstring Format to display the date.
* @param int $unixtimestamp Optional. Unix timestamp.
* @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
* @return string The date, translated if locale specifies it.
*/
function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false )