Skip to content

add date and time information above totp setup instructions#772

Merged
kasparsd merged 3 commits intoWordPress:masterfrom
masteradhoc:patch-1
Feb 13, 2026
Merged

add date and time information above totp setup instructions#772
kasparsd merged 3 commits intoWordPress:masterfrom
masteradhoc:patch-1

Conversation

@masteradhoc
Copy link
Contributor

Fixes #357

What?

Adds a one-line server date/time display to the TOTP setup UI so users can verify the server clock and timezone when registering an authenticator app.

Why?

TOTP relies on timestamps; a misconfigured server clock or timezone causes OTPs to be invalid. Showing the current server date/time helps site administrators and users quickly confirm the server time is correct and avoid TOTP failures.

How?

Inserted a single translatable line above the QR/secret instructions in user_two_factor_options():
Uses date format and time format set in wordpress settings to format it appropriately.

Testing Instructions

  1. go to edit a user
  2. you can see the TOTP setup in the usual way
  3. apply changes
  4. refresh the page and see the server date/time formatted in your local site format

Screenshots or screencast

  1. Version with timezone associated to a city and date format F j, Y and timeformat g:i a
image
  1. Version with timezone associated set to UTC+1 and date format d.m.Y and timeformat H:i
image

Changelog Entry

Added - Show server date/time on TOTP setup so administrators can verify timezone/clock to avoid invalid OTPs

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: masteradhoc <[email protected]>
Co-authored-by: georgestephanis <[email protected]>
Co-authored-by: My1 <[email protected]>
Co-authored-by: kasparsd <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

$datetime = wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) );
$tz_display = wp_timezone_string();
?>
<p class="two-factor-server-datetime">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thought -- would it be worth adding in a data-attribute to this p with the current timestamp and tz, so we could do a bit of js to do comparisons on page load and flag if there's a notable discrepancy with the client browser?

Possibly overengineering.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I also advocated years ago for trying to autodetect timezone in js and suggesting that on the site's options page, or autopopulating it on new sites)

Copy link

@My1 My1 Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt even need time and tz in a data attribute for scripting, just throw the unixtime in there, stupidly simple and impossible to misinterpret (it's literally just a number) and the client could process this then into whatever is needed.
while obviously everyone has their own taste, at least imo for 99% of things that is processing unixtime is the nicest to handle, rather than working back and forth from all sorts of time display formats meant for human usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! i think a JS note would be nice to show the user if a potential mismatch is there. not sure how its in line with WordPress Core standards though. A data-attribute should be fine so i added one for the review

<p class="two-factor-server-datetime" data-server-epoch="1770849123"> Your server date and time is F......</p>

What do you think? @georgestephanis @My1

Copy link
Collaborator

@georgestephanis georgestephanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thought for a possible enhancement, but nothing worth holding this up over. Worth doing, I think.

@kasparsd kasparsd merged commit 52d6389 into WordPress:master Feb 13, 2026
29 checks passed
@masteradhoc masteradhoc deleted the patch-1 branch February 13, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display the current server date and time when attempting to register OTP

5 participants