$dt = '2013-03-15 02:15:33';
$dateTimeZone = new DateTimeZone('Asia/Karachi');
$dateTime = new DateTime($dt, $dateTimeZone);
$year = $dateTime->format('Y');
$month = $dateTime->format('m');
$day = $dateTime->format('d');
$hours = $dateTime->format('H');
$minutes = $dateTime->format('i');
$seconds = $dateTime->format('s');
$message_time_ago = $year . '-' . $month . '-' . $day . ' ' . $hours . ':' . $minutes. ':' . $seconds;
但它返回相同'2013-03-15 02:15:33',但它应该是'2013-03-15 11:15:33'。 任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
您就是这样做的:
$date = new DateTime('2013-03-15 02:15:33');
$date->setTimezone(new DateTimeZone('Asia/Karachi'));
echo $date->format('Y-m-d H:i:s'); // 2013-03-15 07:15:33