Use date_timezone_set to set 2017/10/24 00:00:00 in timezone Asia/Tokyo.
$date = '2017-10-24';
$timezone = 'Asia/Tokyo';
$tokyoTime = date_timezone_set(new DateTime($date), new DateTimeZone($timezone));
echo $tokyoTime;
If $date is null, $tokyoTime will be the time of right now in Tokyo.
Set $tokyoTime to null when $date is null.
$tokyoTime = empty($date) ? '' : date_timezone_set(new DateTime($date), new DateTimeZone($timezone));
Set format
$tokyoTime = empty($date) ? '' : date_format(date_timezone_set(new DateTime($date), new DateTimeZone($timezone)), 'Ymd H:i');
$date = '2017-10-24';
$timezone = 'Asia/Tokyo';
$tokyoTime = date_timezone_set(new DateTime($date), new DateTimeZone($timezone));
echo $tokyoTime;
If $date is null, $tokyoTime will be the time of right now in Tokyo.
Set $tokyoTime to null when $date is null.
$tokyoTime = empty($date) ? '' : date_timezone_set(new DateTime($date), new DateTimeZone($timezone));
Set format
$tokyoTime = empty($date) ? '' : date_format(date_timezone_set(new DateTime($date), new DateTimeZone($timezone)), 'Ymd H:i');
No comments :
Post a Comment