Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

max. future date of SS_datetime??


Reply

5 Posts   1418 Views

Avatar
fj

8 March 2011 at 3:46am Community Member, 7 Posts

what is the maximum future date of an SS_Datetime field in a model??
I try to set "9999-31-12 23:59:00" and "2099-31-12 23:59:00" via YAML fixture file but both values do not work.
"2029-12-11 23:59:00" works fine. hmmm.
thanks!

Avatar
Devlin

10 March 2011 at 6:16am Community Member, 215 Posts

I try to set "9999-31-12 23:59:00" and "2099-31-12 23:59:00"
There is no 31st month.

The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
http://dev.mysql.com/doc/refman/5.1/en/datetime.html

Avatar
fj

10 March 2011 at 8:45pm Community Member, 7 Posts

Sorry, wrote it down the wrong way.

now, I try to set "2039-12-31 23:59:00" but that does not work. I guess it's some 32bit unix timestamp issue. Could the default SS date parser be an issue here?

Avatar
Devlin

10 March 2011 at 9:51pm Community Member, 215 Posts

I have no problem to save or parse that kind of date. Did you check your database and tried to insert the date via phpMyAdmin? May be it's a formatting issue with DateField.

Avatar
fj

10 March 2011 at 11:15pm (Last edited: 10 March 2011 11:18pm), Community Member, 7 Posts

OK, got it fixed. here is how:

# when setting the date value to an SS_Datetime field by string (like "2039-12-31 23:59:00") the setValue method of SS_Datetime converts this string into a unix timestamp using strtotime. That timestamp is used to create a formatted string ('Y-m-d H:i:s') representing the date. but the timestamp seems to have some limitation (see http://www.tareeinternet.com/forum/knowledgebase/53-detailed-timestamp-information-tutorial.html)

# so I extended the SS_Datetime class and overwrote the setValue() method. This allows me to use the php DateTime class (since php 5.2) to create the formatted string ('Y-m-d H:i:s') and set the objects value directly.

# now I use the extended "eXSS_Datetime" classes in my models