Jump to content


Photo

Suspected leap year problem with "created" variable

solved dates times leap year

  • Please log in to reply
2 replies to this topic

#1 ClintonSkakun

ClintonSkakun

    Jr. Member

  • Members
  • PipPip
  • 24 posts
  • 12

Posted 02 March 2012 - 08:11 PM

I'm having a problem with incorrect "created" dates.

"created" dates are showing one day ahead. I don't think it's the server because I did a echo date("Y") and it shows the correct date. I'm doing this echo date("Y m d", $page->created); to show the page/article date.

The timezone is set to New York time, which is fine as it's close enough.

I'm wondering if this problem is coming up because it's a leap year. I didn't want to fish around the core to find out how "created" was set after looking around and not being able to find it.

Anyone have any thoughts on this, or how to fix it?

#2 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3108

  • LocationAtlanta, GA

Posted 02 March 2012 - 09:30 PM

The 'created' field is set from a MySQL 'NOW()' command (current timestamp), rather than from ProcessWire or PHP. I would guess that your MySQL may be configured for a different timezone? I've not seen this difference before. Try this in a MySQL client (like PhpMyAdmin):

SHOW VARIABLES LIKE  '%time_zone%'

Based on your NY timezone, it should say this:

system_time_zone EST
time_zone SYSTEM


#3 ClintonSkakun

ClintonSkakun

    Jr. Member

  • Members
  • PipPip
  • 24 posts
  • 12

Posted 02 March 2012 - 11:28 PM

Thanks Ryan,

That's the problem exactly. It's using a different timezone for the MySQL database.





Also tagged with one or more of these keywords: solved, dates, times, leap year

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users