MySQL convert int to timedate?
Started by
admin
, Apr 19 2007 03:58 PM
#1
Posted 19 April 2007 - 03:58 PM
#2
Posted 19 April 2007 - 06:17 PM
hi admin, and welcome to G2G!
As for your problem, why not just define the date and time as "datetime" in the first place instead of "int"?
-stettybet0
As for your problem, why not just define the date and time as "datetime" in the first place instead of "int"?
-stettybet0
#3
Posted 19 April 2007 - 08:49 PM
I have 1,000+ rows sorted using a date field. If I change them all to a default they won't be in any kind of order. I'd also prefer to keep the date field correct.
#4
Posted 20 April 2007 - 12:36 AM
I am presuming the integer is a time stamp, is which case you can do
That will produce something like 1989-12-23 depending on the $timestamp
EDIT: http://au3.php.net/m...nction.date.php
$date = date("Y-m-d",$timestamp);
That will produce something like 1989-12-23 depending on the $timestamp
EDIT: http://au3.php.net/m...nction.date.php
Edited by Michael, 20 April 2007 - 12:37 AM.
#5
Posted 25 April 2007 - 12:03 PM
I want to change the actual data in the table, not parse it with PHP. Looks like FROM_UNIXTIME will work:
http://dev.mysql.com...n_from-unixtime
http://dev.mysql.com...n_from-unixtime
#6
Posted 25 April 2007 - 06:36 PM
If your only dealing with about 1000 rows it would be easy to get the date, change it, then update it. But useing pure SQL would be easy enough too.
I personally doing the exact opposite, and changing all to a time stamp (unix time) because it is more flexible, I can easily change it for time zone differences or print it in a number of different formats.
I personally doing the exact opposite, and changing all to a time stamp (unix time) because it is more flexible, I can easily change it for time zone differences or print it in a number of different formats.
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users