Bash time to mysql datetime Bash time to mysql datetime bash bash

Bash time to mysql datetime


You can write:

date +'%F %T'

which will print something like:

2012-03-04 11:56:54

(But as zerkms says, it's probably better to just use NOW() within MySQL.)


Equivalent of @ruakh 's answer, in expanded form:

date +'%Y-%m-%d %H:%M:%S'

which will print something like:

2014-04-14 11:33:48

Useful if some of the date stamp separator characters aren't valid for one use or another.