# Converting a date to mysql format

**URL:** <https://www.ruby-forum.com/t/converting-a-date-to-mysql-format/164958>\
**Category:** Rails\
**Created:** [April 7, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/converting-a-date-to-mysql-format/164958 "2009-04-07T20:45:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 7, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/converting-a-date-to-mysql-format/164958/1 "2009-04-07T20:45:01Z")

</div>

Is there an easy way to convert ‘13-Mar-2009 20:55 PDT’ into something  
that ruby understands, so that I can output it in a format that mysql  
understands?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 7, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/converting-a-date-to-mysql-format/164958/2 "2009-04-07T20:55:34Z")

</div>

Chris.Mohr wrote:

> Is there an easy way to convert ‘13-Mar-2009 20:55 PDT’ into something  
> that ruby understands, so that I can output it in a format that mysql  
> understands?

Does this work?

t = Time.parse(‘13-Mar-2009 20:55 PDT’)  
p t.to\_s(:db)
