Date & Time Snippets for WordPress

Last updated 3 months ago

PHP
$time_now          = new DateTimeImmutable(
    'now',
    wp_timezone()
);
$time_tonight      = new DateTimeImmutable(
    'today 24:00',
    wp_timezone()
);
$seconds_remaining = $time_tonight->getTimestamp() - $time_now->getTimestamp();

All code snippets are licensed GPLv2 or later unless otherwise stated.