note 35392 modified in ref.calendar by danbrown

From: Date: Sun, 20 Jul 2008 01:52:20 +0000
Subject: note 35392 modified in ref.calendar by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141916@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. <?php 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); } ?> --was-- 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); } http://php.net/manual/en/ref.calendar.php

« previous php.notes (#141916) next »