Welcome Guest, Not a member yet? Register   Sign In
gmt_to_local() -is it possible to change format
#1

[eluser]blorriman[/eluser]
I'm using gmt_to_local() and it works fine. The output is "2011-05-05 10:29 AM".

Is there anyway to reformat it so the output could be "Thursday May 5, 10:29AM"?
#2

[eluser]toopay[/eluser]
Why not? Use date() and strtotime() to wrap it and generates your date format.
#3

[eluser]blorriman[/eluser]
Thanks, I found a unix_to_human snippet with formatting, so I combined it as follows:
Code:
$timestamp = now();
$timezone = $row->zone;
$daylight_saving = TRUE;

$now = gmt_to_local($timestamp, $timezone, $daylight_saving);

function unix_timestamp_to_human($timestamp = "", $format = 'D M d - h:i a') {
    if (empty($timestamp) || !is_numeric($timestamp))
        $timestamp = time();
        return ($timestamp) ? date($format, $timestamp) : date($format, $timestamp);
    }

echo unix_timestamp_to_human($now); //Return: Thu May 05 - 03:59 pm




Theme © iAndrew 2016 - Forum software by © MyBB