Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Extremely weird mktime() problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mastab0323
Smarty Rookie


Joined: 01 Jul 2005
Posts: 27

PostPosted: Tue Jan 17, 2006 3:34 am    Post subject: Extremely weird mktime() problem Reply with quote

This is really weird and I dont see any reason why the mktime() function would do this, but it poses a problem. Here is the php:

print '1-1-1950: '.mktime(0,0,0,1,1,1950).'<br />1-1-1960: '.mktime(0,0,0,1,1,1960).'<br />1-1-1970: '.mktime(0,0,0,1,1,1970);

Here is what it printed out:

1-1-1950: -14462
1-1-1960: -14462
1-1-1970: 21600

If you take a look at the function manual on php.net for mktime it says this:

Before PHP 5.1.0, negative timestamps were not supported under any known version of Windows and some other systems as well. Therefore the range of valid years was limited to 1970 through 2038.

Well here's the problem:
When I want to store a date of birth, many times its before 1970. The html_select_date function requires a timestamp to auto select the date. So as a result I've been storing date of birth's as timestamps in the database, those timestamps have been generated by the mktime function.

So how in the world should I store the date of birth in a database and convert it into a timestamp so that html_select_date will auto select the proper date if mktime wont return the proper number for the date?

Thanks for your help.[/b]
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jan 17, 2006 7:56 am    Post subject: Reply with quote

the range of timestamps is quite limited and should not be used for things like birthdays.

but html_select_date is not limited to timestamps, you can pass your preselected date in the format time=YYYY-MM-DD with years from about 0000 to 9999.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP