RE: [PHP] Date Localization - Australian

From: Date: Thu, 01 May 2003 06:34:23 +0000
Subject: RE: [PHP] Date Localization - Australian
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145906@lists.php.net to get a copy of this message
<? function formatDateFromStamp($stamp) { $year4 = substr($stamp,0,4); $year2 = substr($stamp,2,2); $month = substr($stamp,4,2); $day = substr($stamp,6,2); $hour = substr($stamp,8,2); $min = substr($stamp,10,2); $sec = substr($stamp,12,2); if($hour >= 12) { $ampm = "pm"; } else { $ampm = "am"; } return "{$day}/{$month}/{$year2} {$hour}:{$min}:{$sec}{$ampm}"; } echo formatDateFromStamp('20030430121556'); ?> This will echo 30/04/03 12:15:56pm, which seems to be what you want -- why do you need to go through mktime, http://www.php.net/manual/en/function.mktime.php AS YOU SEE ON THE MANUAL PAGE, mktime() GIVES A UNIX 'epoch' TIMESTAMP and where is the locale issue? THE LOCALE ISSUE IS, MY APP HAS OPTIONS FOR NUMEROUS LANGUAGES. DATES ARE DISPLAYED DIFFERENTLY TO AUSTRALIA IN THE USA I WANT TO USE ONE SIMPLE FUNCTION (THAT USES strftime() ) TO OUTPUT A LOCALE-SPECIFIC TIME WITH A GIVEN TIMESTAMP (EPOCH OR OTHER), THE SPECIFIC LOCALE IS SET USING setlocale() AT APPLICATION CONFIG TIME.. Really, I'd be throwing away the stamps you're currently using, and just using unix epoch time stamps (the number of seconds since 1970). DOING SO WOULDNT SOLVE MY PROBLEM. ANY MORE SUGGESTIONS WOULD BE APPRECIATED.

« previous php.general (#145906) next »