Jump to content

Date fieldtype reverts to 12/31/1969


RyanJ
 Share

Recommended Posts

It's been too long. Finally got to get back to PW after wading in some MODX development for a while. Anyhow, I am a bit stumped on something. 

I have incorporated a date field and for some reason it converts back to 12/31/1969 after saving the page. When I add a date picker to the field, it does not even offer the current year. It offers a few years from the 70's which I hear were good years, but wont help me here. I have tried multiple configurations in the settings but ultimately end up with the same value.

echoing out the date("m/d/Y") prints the correct date

time zone is set in both my config file and php.ini

  • php.ini - date.timezone = America/New_York
  • config - $config->timezone = 'America/New_York';
  • pw version - 2.7.2

Thanks for any suggestions and its good to be back working with pw.

Link to comment
Share on other sites

I figured out the issue. User error and some default behavior in the mix. When an invalid date format is entered for example "2012", the date reverts back to 1969-12-31 after page save. I guess that is the default date input format, because if I select none, it reverts back to that. Can someone confirm this is normal behavior.

Thanks for all the suggestions and assistance so far.

  • Like 1
Link to comment
Share on other sites

1 Jan 1970 is the start of the Unix epoch. As you are no doubt aware, date/times are stored in the db as seconds after that point. Haven't looked into it too deeply, but I should imagine that refers to UTC (broadly equivalent to GMT), so at 0 seconds UTC your time zone will be sometime on 31 Dec 1969.

tldr; the db is returning 0.

  • Like 2
Link to comment
Share on other sites

That does make sense Dave, thanks. However maybe I am misunderstanding how this fields settings works. Under the input tab on this fields settings, If I modify the "Date Input Format" to none and then modify the "Date Input Format Code" to "Y" per PHP Date then an acceptable format for this field should be the full year ie "2012". Is this not correct?

When doing so the value reverts back to 1969 and the value stored in the DB is 1969-12-31 19:33:32

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...