Jump to content

Local singapore time


sungpeng

Recommended Posts

Find out how off that time is compared to what you want. Then just set an off set based on that. Say it's 1 hour ahead of what you want, you'd do:

 

echo date("l dS of F Y h:i:s A", time()-3600);

Link to comment
Share on other sites

date_default_timezone_set('Asia/Singapore');
$time=date('D,F j, Y, H:i:s A');
$insert_student=mysql_query("insert into listings (listdate) values ('$time')");

The setting for "listdate" field is datetime.

Can I know how what should I input "default" in mysql?

 

$time=date('D,F j, Y, H:i:s A');

Check also how to make it 24 hours. I find it difficult to insert into mysql the PM & AM if listdate setting is datetime default is 0000-00-00 00:00:00

Link to comment
Share on other sites

The format of a DATETIME field  is YYYY-MM-DD HH:MM:SS. There are two main reasons for that format -

 

1) The amount of storage used by a DATETIME has been optimized and it only takes 8 bytes. The format used by date('D,F j, Y, H:i:s A') takes around 31 bytes. This also means that queries involving a DATETIME value are optimized to execute as quick as possible.

2) Dates in the format YYYY-MM-DD can directly be sorted and compared.

 

You would produce values using date('Y-m-d H:i:s'). You can also set the timezone that the mysql server uses for your connection and use the mysql NOW() function in your query to give the same results. See the 'Per-connection time zones' section at this link - http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html

 

To format a DATETIME field when you SELECT it, use the mysql DATE_FORMAT() function - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.