Does anybody know a php equivalent to the foxbase function ctod()?

Ben-Errol

New member
I'm trying to convert a 5 digit number to a constant date: 01/01/1900. With foxbase, the syntax is ctod('01/01/00') + x , where x is the 5 digit, result set is a date.
I'm currently using php and want to do the same, taking that 5 digit and adding it to a date to result in a date. Anyone know if this is possible? Thanks!
 
I suppose it would depend on exactly what your 5 digit number is to begin with.

php has the ever useful strtotime() and date() functions. The first takes a date string and converts it to a unix timestamp. The second takes a unix timestamp and converts it to a date string (see php.net for syntax).

You could do something like date('m/d/y', (strtotime('01/01/00') + x)), where x is seconds. That would basically convert your date string to a timestamp, add some number of seconds to it, and then convert it back to a date string.

But I'm not familiar with the ctod() function so I don't really know what it returns.
 
Back
Top