note 35392 added to ref.calendar

From: Date: Fri, 29 Aug 2003 13:55:20 +0000
Subject: note 35392 added to ref.calendar
Groups: php.notes 
Request: Send a blank email to php-notes+get-55303@lists.php.net to get a copy of this message
I solved a problem with Julian dates that are used in the JD Edwards ERP package (running on AS/400). The Julian format for this system is as follows: CYYDDD Where C is 0 for 1900 and 1 for 2000 DDD is the day of the year count I used the mktime built-in php function to convert dates to the normal DD/MM/YYYY format. This function will convert dates that are between 1970 and 2038 (limitation of unix timestamps and the mktime function) The $jde_date var needs to be a 6 len STRING.... if you use a numeric var type it will drop the leading 0 for any date that represents 1900.... this will botch the substr functions and thus make the whole thing wrong. function jde_date_conv($jde_date) { $ct = substr($jde_date,0,1); $yr = substr($jde_date,1,2); $dy = substr($jde_date,3,3); if($ct == 0) $yr_pfx = 19; if($ct == 1) $yr_pfx = 20; $tlt_yr = $yr_pfx.$yr; $base_time = mktime(0,0,0,1,0,$tlt_yr); $unix_time = ($dy * 86400) + $base_time; return date("m/d/Y" , $unix_time); } ---- Manual Page -- http://www.php.net/manual/en/ref.calendar.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35392 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35392&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35392&report=yes

« previous php.notes (#55303) next »