That code wil only display vps time if im not wrong, so lớn set ur own country time u must use other code
Bạn đang xem: Asia/singapore, how to show local singapore time using php
You can set the timezone that php uses - http://us.php.net/manual/en/datetime.configuration.php#ini.date.timezone
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 đầu vào "default" in mysql?
$time=date("D,F j, Y, H:i:s A");
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 lớn 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 phối the timezone that the mysql hệ thống uses for your connection & use the mysql NOW() function in your query to give the same results. See the "Per-connection time zones" section at this links - 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
Xem thêm: Bí Quyết Dạy Con Của Người Nhật Khiến Các Mẹ Phải "Ngả Mũ", 9 Cách Dạy Con Thông Minh Của Người Nhật
You can post now và register later.If you have an account, sign in now to lớn post with your account.
× Pasted as rich text. Restore formatting
Only 75 emoji are allowed.
× Your link has been automatically embedded. Display as a links instead
× Your previous content has been restored. Clear editor
× You cannot paste images directly. Upload or insert images from URL.
PHP FreaksPowered by Invision Community
We have placed cookies on your device lớn help make this website better. You can adjust your cookie settings, otherwise we"ll assume you"re okay lớn continue.