Re: Australian Date Localization

From: Date: Wed, 30 Apr 2003 09:11:50 +0000
Subject: Re: Australian Date Localization
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145738@lists.php.net to get a copy of this message
In article <NGBBIAJCILLOIJPKMOIFIEIDDIAA.luke@taborvision.com>, luke@taborvision.com says... > I need help with displaying an australian version of the current date and > time. > > I've set the locale for my application using: setlocale (LC_ALL, 'en'); > > Here is a class method I am using to return a date/time string > > /** > * Displays a human-readable version of a unix timestamp. > * > * @access public > * @param string timestamp A unix timestamp > * @return string > */ > function dateAndTime($timestamp) > { > // Parse input as a unix timestamp and list each part as separate > variable > list($year,$month,$day,$hour,$minute,$second) = > sscanf($timestamp,"%4s%2s%2s%2s%2s%2s"); > > // Return a formatted date/time according to our preferred locale > return strftime('%c', > mktime($hour,$minute,$second,$month,$day,$year)); > } > > Here is a sample command with a timestamp as input: echo > dateAndTime('20030430121556'); > > Here is output from the above command: 04/30/03 12:15:56 PM > > NOTE THAT THE DATE AND MONTH NEED TO BE INTERCHANGED!!!!!!!! > > Please help, this is driving me nuts.. I dont know how to set the locale > speficically for Australia or if it is even possible with PHP.. Think you want the date() function - then you can format how you like a lot more simply. Assuming $timestamp is a Unix timestamp: date("d/m/y h:I:s A",$timestamp) should be all you need. -- Quod subigo farinam

« previous php.general (#145738) next »