"Matt Harting" <mharting (AT) micahtek (DOT) com> wrote
Quote:
Does someone have a PHP script that will do ICONV/OCONV of pick dates?
I have pulled some data from an MV box and have internal dates. I need
to OCONV to display and ICONV before writing them back.
Thanks.
Matt |
Tell ya what, I'll tell you how and YOU make the script.
PHP bases dates on the date of the Unix Epoch (01/01/1970). Somewhat like
MV, this date can be represented in a numeric string but unlike MV, this
string is the number of seconds since 01/01/1970 whereas MV uses the number
of days since 12/31/1967.
So, there is a difference of 732 days between the two dates (date 0 in PHP
would be date 732 in MV). Therefore, you would take the MV date and subtract
732. Next, you have to convert this number to seconds. there are 86400
seconds in a day. Multiply the result above by 86400 and you have your
numeric string that represents your date in PHP. Example:
MV date for 02/09/2006 = 13920
(13920 - 732) * 86400 = 1139443200
Now, use the strtotime function to convert that to a date in PHP
Going the reverse direction, use the mktime function to convert the date you
want converted to the numeric representation of seconds since 01/01/1970.
Reverse the calculation above ((1139443200 / 86400) + 732 = 13920) and you
have your MV date in internal format.
HTH
-Bruce