dsp_099
dsp_099

Reputation: 6121

How to retrieve time without the offset number at the end?

Time.now will produce something like:

2013-07-24 22:23:08 -0700

I want:

2013-07-24 22:23:08

for subsequent entry into a DB. Gotta be something simple, but I didn't find it in Time docs. Writing Time.now.to_s[0..19] sounds like bad programming.

Upvotes: 1

Views: 809

Answers (1)

Debadatt
Debadatt

Reputation: 6015

You can get this by

Time.now.to_formatted_s(:db)

You can find different formats for to_formatted_s from here

or

Time.now.strftime("%F %T")

Hope this could help you

Upvotes: 7

Related Questions