Skip to content

Discourage use current_time( 'timestamp' ) #1791

@Rarst

Description

@Rarst

Is your feature request related to a problem?

current_time() with timestamp or U format produces a "WordPress timestamp", a sum of Unix timestamp and current time zone offset.

While historically entrenched in core, the use of such timestamps is deeply problematic and we are working on eliminating them in favor of real Unix timestamps and full interoperability with PHP.

Describe the solution you'd like

  • current_time( 'timestamp', true ) / current_time( 'U', true ) are equivalent to time() and should be replaced with it
  • current_time( 'timestamp' ) / current_time( 'U' ) should be discouraged in favor of requesting non-timestamp format, or otherwise refactoring the usage

Additional context (optional)

The use of current_time( 'timestamp' ) had been mostly eliminated from core in #40657. Minimal usage in unit tests and older functions that must operate with WP timestamps for backwards compatibility reasons remains.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions