Format Date
This little function was a request from a user who wanted a PHP function to format a UNIX timestamp. The user also requested that the function have an option of defaulting to the current timestamp, then, set the time zone to the local time in Sydney Australia. You could of course set the default timezone to any timezone as specied in by the date_default_timezone_set function.
<?php
/**
*
* @Standard date format for site display
*
* @param INT UNIX timestamp
*
* @return string
*
*/
function localDate($timestamp=null){
if(is_null($timestamp))
{
$timestamp = time();
}
date_default_timezone_set("Australia/Sydney");
return date('j F Y g:i', $timestamp);
}
?>
Support PHPRO.ORG
Search
PHPRO.ORG Poll
Warning: Participation in PHPRO.ORG polls may incorrectly lead you to believe your opinions matter.

RSS Feed




