note 68112 added to ref.datetime

From: Date: Thu, 13 Jul 2006 16:16:30 +0000
Subject: note 68112 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-114738@lists.php.net to get a copy of this message
Here are some functions that I put together to convert between Unix and Excel (windows) Dates: ############################### # convert_excel2unix function: # Converts excel date/time stamps to unix timestamp. ############################### function convert_excel2unix($excel_v) { $unix_v = (($excel_v - 25569) * 86400); $text_v = gmdate("m/d/Y H:i:s",$unix_v); $unix_v = strtotime($text_v); return $unix_v; }#End of function to convert excel2unix timestamp. ############################### ############################### # convert_unix2excel function: # Converts unix timestamps to excel date/time stamps. ############################### function convert_unix2excel($unix_v) { $excel_arr = array( excel_date_v => "", #numeric: excel style date stamp (no decimal number) excel_dt_v => "", #numeric: excel style date timestamp (Can include decimal) excel_time_v => "", #numeric: excel style timestamp (not a whole number) );#End of excel array. if($unix_v > 86400) { $tz_v = date("Z",$unix_v); #print "Z\t$tz_v\n"; $excel_arr[excel_dt_v] = (($unix_v + $tz_v)/86400) + 25569; #+ 15168 - $excel_arr[excel_date_v] = $excel_arr[excel_dt_v]; if(strstr($excel_arr[excel_dt_v],".")) { $excel_v_arr = explode(".", $excel_arr[excel_dt_v]); $excel_arr[excel_date_v] = $excel_v_arr[0]; $excel_arr[excel_time_v] = ".".$excel_v_arr[1]; }#End of if excel_dt_v contains a period. }#If its a date time stamp. else { $excel_arr[excel_time_v] = $unix_v / 86400; $excel_arr[excel_dt_v] = $excel_arr[excel_time_v]; }#Else its a timestamp only. return $excel_arr; }#End of function to convert excel2unix timestamp. ############################### ---- Server IP: 66.163.161.117 Probable Submitter: 144.226.173.68 (proxied: 172.19.134.127) ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.datetime.php Edit -- http://master.php.net/note/edit/68112 Del: integrated -- http://master.php.net/note/delete/68112/integrated Del: useless -- http://master.php.net/note/delete/68112/useless Del: bad code -- http://master.php.net/note/delete/68112/bad+code Del: spam -- http://master.php.net/note/delete/68112/spam Del: non-english -- http://master.php.net/note/delete/68112/non-english Del: in docs -- http://master.php.net/note/delete/68112/in+docs Del: other reasons-- http://master.php.net/note/delete/68112 Reject -- http://master.php.net/note/reject/68112 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114738) next »