Opened 10 years ago
Closed 6 years ago
#28614 closed enhancement (worksforme)
Add microtime support to current_time()
Reported by: | uuf6429 | Owned by: | chriscct7 |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Date/Time | Keywords: | has-patch |
Focuses: | Cc: |
Description
current_time()
is currently limited to precision to at most, seconds.
I propose adding current_time('microtime')
functionality.
The proposed changed affects wp-includes/functions.php
, line 67:
case 'microtime':
return ( $gmt ) ? microtime(true) : microtime(true) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
break;
Also, considering this may require better performing code ... I was thinking that perhaps get_option() ... etc
should be replaced with a cache (and update_option()
should be able to update/reset the cache).
Attachments (1)
Change History (6)
#1
in reply to:
↑ description
@
10 years ago
#2
@
10 years ago
- Keywords has-patch added
Adding a sample with the suggested change, break;
is omitted as the function execution is interrupted anyway due to the return
statement in the case.
#4
@
6 years ago
current_time()
is a complete disaster (as most things that juggle manual time zone offsets).
The concept of "WordPress timestamp" with time zone offset is deeply problematic and we should be moving towards dropping it completely. Expanding functionality that relies on it is just makes that harder.
#5
@
6 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from reviewing to closed
I am working on eliminating timestamp
use of current_time()
in #40657, so now I am even more set that we shouldn't be expanding its "local" time functionality.
WP core doesn't really operate with microtime, and if extension use cases need it — they need to be doing it properly, with sane modern DateTime approach.
Replying to uuf6429:
WordPress has an internal option cache (check the source for
get_option
andupdate_option
), however this is handled inside those functions and is transparent to functions using them.