Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-25-2006, 07:10 PM   #1
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Convert Time String to DATETIME field

What is the best way to convert a time like this:

Sep 21 12:34:56 2006
To something that MySQL can understand like a DATETIME field? Thanks.
Old 09-25-2006, 07:16 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Actually, you've a got a whole BUNCH of different options. Especially if you're calling MySQL from PHP.

Anyway, here's a good place to start:
Old 09-25-2006, 07:20 PM   #3
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Original Poster
Rep: Reputation: 30
Thanks for the reference. Here is what I ended up using:

str_to_date('Sep 21 12:34:56 2006','%b %e %T %Y')
Thanks again


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the ninth (9th) character or field in the output string of rpm -V ? zimon Linux - Distributions 1 08-28-2006 02:47 PM
How to convert string to char? twirl Programming 27 10-13-2005 07:11 AM
Can we specify variable field width in a scanf() format string? skie_knite007 Programming 3 05-13-2005 12:56 PM
convert date time format given in string suchi_s Programming 6 01-10-2005 04:06 AM
Mysql/PHP query problem with datetime field. Pcghost Programming 2 11-11-2003 12:24 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration