RE: [PHP-WIN] dates PHP4 and Access

From: Date: Wed, 05 Jul 2000 00:35:50 +0000
Subject: RE: [PHP-WIN] dates PHP4 and Access
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-850@lists.php.net to get a copy of this message
Here's a function I wrote to get around the problem of MS Access 2000 timestamp conversion. I keep it in an include file, and include it when required. Hope it helps :) Jace _________________ Jason Lee Comp Sys Officer Research Services Deakin University ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ <? /* Microsoft Access Utility Functions * ---------------------------------- * Various functions used with MS Access via ODBC. * * HISTORY: * 20 Jun 2000 - Jace - Added convert_msaccess_timestamp() */ function convert_msaccess_timestamp($msaccess_timestamp) { /* Convert MS Access 2000 timestamp to a php timestamp integer. * MS Access 2000 timestamps are returned in the format YYYY-MM-DD HH:MM:SS * eg: 2000-06-20 17:09:00 * * Year must be at least 1970, otherwise php won't recognise it. This * is because the 16bit php timestamp integer holds the number of seconds * from 01-01-1970. * * PARAMETERS: * string $msaccess_timestamp - timestamp pulled from MS Access 2000 db. * * RETURN VALUES: * int timestamp * * PRE-CONDITIONS: * $msaccess_timestamp must be a valid MS Access timestamp. No date/time * validating is performed in this function. * * HISTORY: * 20 Jun 2000 - Jace - Initial version. Only used with MS Access 2000. */ /* Split MS Access timestamp into integer components. * 111111111 * 0123456789012345678 * YYYY-MM-DD HH:MM:SS */ $msaccess_year = (int) substr($msaccess_timestamp, 0, 4); $msaccess_month = (int) substr($msaccess_timestamp, 5, 2); $msaccess_day = (int) substr($msaccess_timestamp, 8, 2); $msaccess_hour = (int) substr($msaccess_timestamp, 11, 2); $msaccess_minute = (int) substr($msaccess_timestamp, 14, 2); $msaccess_second = (int) substr($msaccess_timestamp, 17, 2); /* Make sure year is at least 1970 */ if($msaccess_year < 1970) $msaccess_year = 1970; /* printf("<p><b>access_timestamp</b> = *%s*<br>\n", $msaccess_timestamp); printf("msaccess_year = *%d*<br>\n", $msaccess_year); printf("msaccess_month = *%d*<br>\n", $msaccess_month); printf("msaccess_day = *%d*<br>\n", $msaccess_day); printf("msaccess_hour = *%d*<br>\n", $msaccess_hour); printf("msaccess_minute = *%d*<br>\n", $msaccess_minute); printf("msaccess_second = *%d*<br></p>\n", $msaccess_second); */ /* Make php timestamp. */ return(mktime($msaccess_hour, $msaccess_minute, $msaccess_second, $msaccess_month, $msaccess_day, $msaccess_year)); } ?> > -----Original Message----- > From: Quintin Blane [mailto:qablane@surfaid.org] > Sent: Wednesday, 5 July 2000 5:46 AM > To: php-windows@lists.php.net > Subject: [PHP-WIN] dates PHP4 and Access > > > I require to report via PHP4 dates acquired from Access 2000 via ODBC > How do I convert the output to a meaningful date? > With no parameter the Date() function gives me current date > and time; with > the date output of ODBC I get what I take to be the start > date for counting > dates in PHP. > > Quintin A Blane > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.windows (#850) next »