Make WordPress Core

Opened 10 years ago

Closed 5 years ago

Last modified 5 years ago

#29063 closed defect (bug) (duplicate)

function current_time( $type, $gmt = 0 ) don't return GMT if 'Y-m-d H:i:s' is pass as type

Reported by: pbearne's profile pbearne Owned by: chriscct7's profile chriscct7
Milestone: Priority: normal
Severity: normal Version: 3.8
Component: Date/Time Keywords: has-patch has-unit-tests bulk-reopened
Focuses: Cc:


Hi Guys

Have been trying to write unit tests for the function current_time() in the functions.php

It works OK if the server/php timezone is GMT but if I run date_default_timezone_set('America/Los_Angeles'); and change the timezone it fails to pass the unit tests

So here are the unit tests and patch that seems to fix it.

It needs better eyes than mine to check this :-) as this a core function


Attachments (1)

current_time.patch (6.3 KB) - added by pbearne 10 years ago.
unit test and patch for current time()

Download all attachments as: .zip

Change History (11)

10 years ago

unit test and patch for current time()

This ticket was mentioned in IRC in #wordpress-dev by pbearne. View the logs.

10 years ago

#3 @SergeyBiryukov
10 years ago

  • Component changed from General to Date/Time

#4 @pbearne
10 years ago

hope the unit tests help

#5 @pbearne
10 years ago

  • Keywords unit-tests added

#6 @tellyworth
10 years ago

  • Version changed from trunk to 3.8

#7 follow-up: @chriscct7
8 years ago

  • Keywords has-patch added; unit-tests removed
  • Owner set to chriscct7
  • Status changed from new to reviewing

Patch still applies. Needs review.

#8 in reply to: ↑ 7 @pbearne
8 years ago

  • Keywords has-unit-tests added

Replying to chriscct7:

Patch still applies. Needs review.

Ping me if we need to change anything to get this in


#12 @Rarst
5 years ago

  • Keywords bulk-reopened added
  • Resolution set to duplicate
  • Status changed from reviewing to closed

Duplicate of #40653.

Folding this into a general rewrite of the function.

Note: See TracTickets for help on using tickets.