Hướng dẫn dùng singapur timezone trong PHP

I wants to display singapore time. I have tried out like this,

answered Jan 21, 2014 at 7:32

KaushikKaushik

2,0241 gold badge22 silver badges29 bronze badges

There are two methods to display current timestamp. Either you use "localtime" PHP method to display the current local time in an Array OR you can use DateTimeZone to display the specific timezone date-time. Here is the code ..

answered Jan 21, 2014 at 7:37

AJ101AJ101

691 silver badge8 bronze badges

date_default_timezone_set['Asia/Singapore'];
$todayDate=date["Y-m-d H:i:s"];

answered Aug 17, 2021 at 13:02

write date_default_timezone_set['Asia/Singapore']; before displaying the date.

for inputting the value into database, use the date["Y-m-d H:i:s"] format in php to match the column, or make the column type as varchar[50] to store date as string.

answered Jan 21, 2014 at 7:27

ArcherArcher

1,1424 gold badges12 silver badges34 bronze badges

You can use this

//ir2.php.net/manual/en/datetime.construct.php

// Current date/time in the specified time zone. $date = new DateTime[null, new DateTimeZone['Asia/Singapore']]; echo $date->format['Y-m-d H:i:sP'] . "\n";

answered Jan 21, 2014 at 7:32

farzamfarzam

6992 gold badges6 silver badges19 bronze badges

try with date_default_timezone_set[]

answered Jan 21, 2014 at 7:33

Not the answer you're looking for? Browse other questions tagged php or ask your own question.

Chủ Đề