# Little prob with Date.strptime

**URL:** <https://www.ruby-forum.com/t/little-prob-with-date-strptime/161620>\
**Category:** Ruby\
**Created:** [February 27, 2009, 10:29pm UTC](https://www.ruby-forum.com/t/little-prob-with-date-strptime/161620 "2009-02-27T22:29:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [February 27, 2009, 10:29pm UTC](https://www.ruby-forum.com/t/little-prob-with-date-strptime/161620/1 "2009-02-27T22:29:30Z")

</div>

hello  
for some reason, the Date.strptime is mixing up my date. pl see here.  
the date changs from “6/13/2008” to “2020-06-13”

irb(main):001:0\> require ‘date’  
=\> true  
irb(main):006:0\> entry=“6/13/2008”  
=\> “6/13/2008”  
irb(main):007:0\> Date.strptime(entry,’%m/%d/%y’)  
=\> #\<Date: 4918027/2,0,2299161\>  
irb(main):008:0\> nowdate=Date.strptime(entry,’%m/%d/%y’)  
=\> #\<Date: 4918027/2,0,2299161\>  
irb(main):009:0\> nowdate.to\_s  
=\> “2020-06-13”

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [February 27, 2009, 10:50pm UTC](https://www.ruby-forum.com/t/little-prob-with-date-strptime/161620/2 "2009-02-27T22:50:37Z")

</div>

On Feb 27, 3:22 pm, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> irb(main):008:0\> nowdate=Date.strptime(entry,‘%m/%d/%y’)  
> =\> #\<Date: 4918027/2,0,2299161\>  
> irb(main):009:0\> nowdate.to\_s  
> =\> “2020-06-13”

you ned %Y, not %y (note the capitalization). im guessing that since  
%y means yy, its only taking the first 2 digits of your year (20) and  
using that as the year.
