What is correct format, length for this to store in correct way?
vincevincevince
11:49 am on Jan 26, 2011 (gmt 0)
If you use DATETIME as the MySQL field, then you can insert it as NOW() in MySQL - there is no need to control it via PHP.
Practically speaking, if your system is only being used for/from PHP then I usually recommend the UNIX time format and an INT size because it saves converting things on the way in, and converting them on the way out again for use with 'date()' on the display end.
toplisek
12:40 pm on Jan 26, 2011 (gmt 0)
Can be improved timezone with datetime type? date_default_timezone_set ("Europe/Berlin"); $cur_timestamp = time(); $cur_datetime = date("Y-m-d H:i:s",time()); //2011-01-26 13:34:53
1. will work? $cur_datetime = now(); 2. Where is defined UNIX time format within MYSQL?
omoutop
2:19 pm on Jan 26, 2011 (gmt 0)
2. Where is defined UNIX time format within MYSQL?
You can store unix timestamps as integers in your database table. I think this is safe up to 2036.
Note that using of time() will give you the server time. Use caution if your server is in different timezone that you and your users
toplisek
4:48 pm on Jan 26, 2011 (gmt 0)
You mean 2011-01-26 13:34:53 can be format of field as INTEGER I have set date_default_timezone_set ("Europe/Berlin"); to change to clients time zone. Is this ok?