In wordpress I use code below to get today persian's date.
function getDateIntl(?\DateTime $date = null, ?string $locale = null, ?DateTimeZone $timezone = null, $dateFormat)
{
$date = $date ?? new \DateTime();
$locale = $locale ?? \Locale::getDefault();
$formatter = new \IntlDateFormatter(
$locale,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
$timezone,
IntlDateFormatter::TRADITIONAL,
$dateFormat
);
return $formatter->format($date);
}
echo getDateIntl(new DateTime(), "fa@calendar=persian", new \DateTimeZone('Asia/Tehran'), 'eeee، dd MMMM');
Now I'm in single blog posts and want to use this function to convert comments date to perisan defualt function of comment date is: get_comment_date()
defualt funtion of wordpress returns string that I can not replace it with "new DateTime()"
Wordpress has a special hook in which you can do any manipulation with the date when the function
get_comment_date()will be used: