Skip to content

How to use microtime() format in Admin UI - is it possible? #5195

Answered by Deltik
Jimmi08 asked this question in Q&A Core
Discussion options

You must be logged in to vote

Ah, in this case, I would recommend creating your own input field and converting between the Unix epoch and the ISO 8601 time (which looks like 2024-02-14T08:33:28.8829+00:00). You can then change the milliseconds, and when saving, convert the ISO 8601 time back to the database representation (e.g. 1707899608.8829).

Example functions that can convert between the two:

/**
 * Converts a microtime float to an ISO 8601 datetime string.
 *
 * @param float $microtime The microtime float to convert.
 * @return string The ISO 8601 datetime string.
 */
function microtimeToISO8601(float $microtime): string
{
    $seconds = floor($microtime);
    $microseconds = $microtime - $seconds;
    $datetime = 

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Jimmi08
Comment options

@Deltik
Comment options

Answer selected by Jimmi08
@Jimmi08
Comment options

@Jimmi08
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants