Page 1 of 1

Convert to mysql timestamp format?

Posted: Thu Mar 01, 2007 5:29 pm
by aspekt9
How can I convert this: 200703162636

To mysql timestamp format (YYYY-MM-DD HH:MM:SS)?

and if the day is 1 it'll put a 0 in front of it?

Posted: Thu Mar 01, 2007 5:31 pm
by Chris Corbyn

Code: Select all

select from_unixtime($timestamp);

Posted: Thu Mar 01, 2007 5:52 pm
by aspekt9
The unix timestamped isn't stored in the database though. It's retrieved from a form where the user selects the date and time.

Posted: Fri Mar 02, 2007 12:16 am
by feyd
That's not a unix time stamp, but a textual time stamp that MySQL can understand already.

Posted: Fri Mar 02, 2007 11:07 am
by the_last_tamurai
aspekt9 : what is the problem ??
the first form is unix timestamp....and you can easily insert it to database as integer
and play with it bygetdate()
that's what I extract from your question????isn't it??

Posted: Fri Mar 02, 2007 11:22 am
by RobertGonzalez
How can I convert this: 200703162636
What is this 200703162636? Is it a numeric value made up of date parts, or a time stamp, or what? How does it get into that format?

Posted: Fri Mar 02, 2007 1:44 pm
by feyd
As I said, it's not a unix time stamp.

It is in MySQL's timestamp field format. It is legible by MySQL without any special help. Yes, it is composed of date parts without separators. Why? Because there's no need when there is known uniform width for all elements.

Posted: Sat Mar 03, 2007 1:28 am
by the_last_tamurai
:? lol, I didn't notice that the first form is a date without separators
yes, it's not unix timestamp

Posted: Sat Mar 03, 2007 1:14 pm
by RobertGonzalez
Search the MySQL manual for Date and Time functions for a huge list of things you can do with a datetime stamp.