I need to convert the date of my posts to the Jalali calendar.
This is the code I’m using to display the date of the posts in WordPress. I tried using some plugins to change the date but they did not work.
echo get_the_title()
? '<span>'.date( ' j ',strtotime($post->post_date)).'</span>'.date( '/F , Y',strtotime($post->post_date))
: '<a href="'.get_the_permalink().'"><span>'.date( ' j ',strtotime($post->post_date)).'</span>'.date( '/F , Y',strtotime($post->post_date)).'</a>';
You should probably use the
IntlDateFormatterclass inside a function.And then
echo convertDateTime($post->post_date)when showing your posts.For
2023-10-14 12:00:00this gives me۱۴۰۲/۷/۲۲, ۱۵:۳۰which according to Google translates to22.07.1402, 15:30.The IntlDateFormatter class