php convert USA or other timestamp to AsiaBangkok

function mapGMTAsiaBangkok($timestamp)
{
    if(empty($timestamp) || $timestamp == null)
        $timestamp = time();
    $date = new DateTime("@".$timestamp);  // will snap to UTC because of the
                                       // "@timezone" syntax
    /*echo $date->format('Y-m-d H:i:sP') . "<br>";  // UTC time

    $date->setTimezone(new DateTimeZone('Pacific/Chatham'));  
    echo $date->format('Y-m-d H:i:sP') . "<br>";  // Pacific time  */


    $date->setTimezone(new DateTimeZone('Asia/Bangkok'));
    //echo $date->format('Y-m-d H:i:s') . "<br>";  // Bangkok time

    return $date->format('Y-m-d H:i:s');  
}

Related posts:

This entry was posted in php. Bookmark the permalink.