Hello,
We apologize for the issue you are facing with the sitemap timezone format. To change the timezone in your sitemap to reflect Indian Standard Time (IST), you can add a filter to your theme’s functions.php
file. Here’s a code snippet that you can use:
/**
* Filter code to change the timezone in the sitemap
*/
add_filter( 'rank_math/sitemap/lastmod', function( $lastmod ) {
// Set the timezone to India Standard Time
date_default_timezone_set('Asia/Kolkata');
return date('Y-m-d H:i:s P', strtotime($lastmod));
});
This code sets the timezone to Asia/Kolkata, which corresponds to +5:30. After adding this code, your sitemap should display the dates in the desired format.
If you have any further questions or need assistance, feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you further!
Sources:
Resolving Rank Math Schema Markup Related Issues
Hello,
Thank you for contacting support.
You don’t need to change the timezone of the sitemap as that is only used by search engines and we set the timezone to UTC and update the time to reflect that based on the timezone of the website, essentially making sure that the time Google sees is the exact time the page or post was updated.
Besides that, there are no filters to modify the time in the sitemap as that is taken automatically following the steps we illustrated above.
Don’t hesitate to get in touch if you have any other questions.
+00:00 to +5:30 I want this
Hello,
If you still want to change it, you will have to make changes directly to the plugin files. You can edit the wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-timezone.php
file.
And change the UTC
with your preferred timezone on line 40. Since you want UTC +5:30
, the code should be like this:
$date_time = new DateTime( $datetime_string, new DateTimeZone( '+5:30' ) );
Please note that these changes will be overridden by each update and you will have to make the changes again.
Also, there is no benefit in modifying the code, as Google recommends using the UTC timezone and will be able to detect the correct last modified time. That’s why we made this change in the plugin.
Hope that helps. Let us know if you need any other assistance.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.