Make WordPress Core

Opened 7 weeks ago

Closed 7 weeks ago

Last modified 7 weeks ago

#61908 closed defect (bug) (invalid)

wp_date does not support micro seconds.

Reported by: dpeterson1971's profile dpeterson1971 Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.6
Component: Date/Time Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

// This fails because of this line.
$date = wp_date('Y-m-d H:i:s.u',microtime( true ));

if ( null === $timestamp ) {
    $timestamp = time();
} elseif ( ! is_numeric( $timestamp ) ) {
    return false;
}

// Should be changed to this.
if ( null === $timestamp ) {
    $timestamp = time();
} elseif ( ! is_numeric( $timestamp ) || ! is_float($timestamp) {
    return false;
}

Attachments (1)

patch.php (145 bytes) - added by dpeterson1971 7 weeks ago.

Download all attachments as: .zip

Change History (4)

@dpeterson1971
7 weeks ago

#1 @narenin
7 weeks ago

Hi @dpeterson1971

You are very welcome to the Core Trac!

I have tried this and it is working fine, please let me know if I am missing anything.

Please find the code I am using.

$date = wp_date('Y-m-d H:i:s.u',microtime( true ));
var_dump( $date );

https://prnt.sc/uixffJtXw9xo

#2 @dpeterson1971
7 weeks ago

  • Resolution set to invalid
  • Status changed from new to closed

Never mind, not sure what I was doing wrong. Sorry

#3 @SergeyBiryukov
7 weeks ago

  • Description modified (diff)
  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted

No worries, thanks for the follow-up!

Note: See TracTickets for help on using tickets.