Re: Converting a "timestamp"

From: Date: Sun, 19 Feb 2017 10:44:51 +0000
Subject: Re: Converting a "timestamp"
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-325977@lists.php.net to get a copy of this message
On 19/02/17 03:34, Jennifer wrote: > Thanks for the function, Don. That did end up coming in handy, but my main question was about > getting the data out of MySQL and then back in, which I couldn’t really solve. I could get the > data into an array and massage it, but I couldn’t figure out how to get it back in. So I ended up > just exporting the data from the table, manipulating the file in PHP, then importing back into the > table. A round about way, but at least it’s done. Jennifer ... Your problem here is sorting out just what format IS used in the database. If the field is a timestamp, it's stored as a number rather than a string of characters. I think I am right in saying that a Mysql timestamp is as a 32bit unix style seconds count, while a DATETIME is 64 bit with a layout of numbers something like you describe. The Mysql date and time functions take care of any conversions, so it is your client program that is showing the 2017|02|16|04|58|42 which I suspect is 'INTERNAL' format, while you want to use a different 'default' or use the https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format function to give you the correct format. I don't use Mysql much. Firebird has always had a 64 bit timestamp which is 32bits day and 32bits time and other databases use their own internal format. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

« previous php.general (#325977) next »