[drupal-devel] date conversion

Steven Wittens steven at acko.net
Mon Jun 13 09:05:27 UTC 2005


>I was wondering if anyone knows of a decent method of converting dates
>from text to a time.
>
>I did look at strtotime() but it will not convert anything before Jan 1,
>1970 which is a problem since it is going to be used for a date of birth
>field, and some people will be over 35.
>
>Is there is improved strtotime() that will convert to anything to a
>time.
>  
>
As Killes has pointed out, negative timestamps are a problem on Windows 
(and so I've heard, on some of the rarer Unix variants too). This is why 
profile.module has its own routines for handling date fields (as 
birthdays are a common use case). The day, month and year are stored 
separately (well, as a serialized triple). The downside is that 
non-existant dates like "31 February" can be entered.

Without more information there's not much to say... but converting a 
string representation of a birthday to a day/month/year pair is quite 
simple as long as the format is not ambiguous (e.g. d/m/y vs m/d/y). 
Perhaps you could try something in that direction.

Steven




More information about the drupal-devel mailing list