Countdown to a Launch or Deadline Widget
Adds a dashboard widget counting down the days and hours to a date you set, such as a site launch, campaign start or content deadline, to keep the whole team focused.
Opens WPIDE on
Code
// Target date and time (site time zone) and its label.
$wpide_countdown_date = '2026-12-01 09:00';
$wpide_countdown_label = 'Website launch';
add_action( 'wp_dashboard_setup', function () use ( $wpide_countdown_date, $wpide_countdown_label ) {
wp_add_dashboard_widget( 'wpide_launch_countdown', 'Countdown: ' . esc_html( $wpide_countdown_label ), function () use ( $wpide_countdown_date, $wpide_countdown_label ) {
$target = date_create_immutable( $wpide_countdown_date, wp_timezone() );
if ( ! $target ) {
echo '<p>Set a valid date in the snippet.</p>';
return;
}
$left = $target->getTimestamp() - time();
if ( $left <= 0 ) {
printf( '<p style="font-size:16px"><strong>%s</strong> was on %s.</p>', esc_html( $wpide_countdown_label ), esc_html( wp_date( get_option( 'date_format' ), $target->getTimestamp() ) ) );
return;
}
$days = (int) floor( $left / DAY_IN_SECONDS );
$hours = (int) floor( ( $left % DAY_IN_SECONDS ) / HOUR_IN_SECONDS );
printf(
'<div style="text-align:center;padding:10px 0"><div style="font-size:40px;font-weight:700;line-height:1">%d</div><div>days and %d hours until</div><div style="font-size:16px;font-weight:600;margin-top:4px">%s</div><div style="color:#646970">%s</div></div>',
$days,
$hours,
esc_html( $wpide_countdown_label ),
esc_html( wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $target->getTimestamp() ) )
);
} );
} );
Notes
Set the date and time in your site's time zone; after the date passes the widget shows a "done" message.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.