I am using below code in functions.php to set post expiration time, to the last minute/second of the current month:
function func_my_custom_sample_expiration($post_id, $form_data)
{
if (($form_data['id'] == 462) or ($form_data['id']==628)) {
// Modify the automated expiration time to use last minute of last day of current month
// Note that times here are UTC. WordPress then translates to local times.
$new_expiration = mktime(21, 59, 59, date("n"), date("t"));
update_post_meta($post_id, '_cred_post_expiration_time', $new_expiration);
}
}
add_action('cred_save_data', 'func_my_custom_sample_expiration',15,2);
Above code works fine and in the backend in the "Settings for Post Expiration Date", the post expiration shows as December 31, 2017, 23:59 which is correct.
Now, to print expiration date, I use:
[cred-post-expiration id=$active_sample_id format='j F Y, H:i']
It prints December 31, 2017, 21:59 which is wrong as it is two hours earlier.
Also, please note that at my WP General Settings, timezone is set to Athens, which is UTC+2.
This printing of expiration time at two hours difference, looks like a bug to me.
Please check it out.