[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

i have some challenges with the date

Junkone

1/5/2009 4:08:00 PM

here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
however my date.parse switches the month and the day.
how do i fix it.

irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
=> "2009-02-01"
3 Answers

James Gray

1/5/2009 4:16:00 PM

0

On Jan 5, 2009, at 10:10 AM, Junkone wrote:

> here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
> however my date.parse switches the month and the day.
> how do i fix it.
>
> irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
> => "2009-02-01"

You can specify a format for the parse:

>> Date.strptime("02/01/2009", "%d/%m/%Y").to_s
=> "2009-01-02"

Hope that helps.

James Edward Gray II

Sebastian Hungerecker

1/5/2009 4:18:00 PM

0

Junkone wrote:
> here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
> however my date.parse switches the month and the day.
> how do i fix it.
>
> irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
> => "2009-02-01"

>> Date.strptime("02/01/2009","%d/%m/%Y").to_s
=> "2009-01-02"

HTH,
Sebastian
--
NP: Mindcrime - Burning Glass (edit)
Jabber: sepp2k@jabber.org
ICQ: 205544826

Dean F.

6/2/2013 6:00:00 AM

0

Simon & Garfunkel are now officially representing the sounds of silence.

> Leaving...

> Louie Louie - Kingsmen
>
> (I Can't Get No) Satisfaction - Rolling Stones
>
> Like A Rolling Stone - Bob Dylan
>
> Light My Fire - Doors
>
> She Loves You - Beatles
>
> You Really Got Me - Kinks
>
> In The Midnight Hour - Wilson Pickett
>
> My Generation - The Who
>
> Proud Mary - Creedence Clearwater Revival
>
> Dock Of The Bay - Otis Redding
>
> House Of The Rising Sun - Animals
>
> Be My Baby - Ronettes
>
> Somebody To Love - Jefferson Airplane
>
> Soul Man - Sam & Dave
>
> I Get Around - Beach Boys
>
> Reach Out, I'll Be There - Four Tops
>
> Gimme Some Lovin' - Spencer Davis Group
>
> Ain't Too Proud To Beg - Temptations
>
> Dancing In The Street - Martha & the Vandellas
>
> Jumpin' Jack Flash - Rolling Stones
>
> Born To Be Wild - Steppenwolf
>
> Oh, Pretty Woman - Roy Orbison
>
> Sympathy For The Devil - Rolling Stones
>
> Ticket To Ride - Beatles
>
> The Tracks Of My Tears - Miracles
>
> For What It's Worth - Buffalo Springfield
>
> People Get Ready - Impressions
>
> Honky Tonk Women - Rolling Stones
>
> Bad Moon Rising - Creedence Clearwater Revival
>
> Revolution - Beatles
>
> Georgia On My Mind - Ray Charles
>
> Bring It On Home To Me - Sam Cooke
>
> You've Really Got A Hold On Me - Miracles
>
> A Hard Day's Night - Beatles
>
> You Keep Me Hangin' On - Supremes
>
> She's Not There - Zombies
>
> All Day And All Of The Night - Kinks
>
> God Only Knows - Beach Boys
>
> Under The Boardwalk - Drifters
>
> Gloria - Them / Shadows Of Knight
>
> In My Life - Beatles
>
> I Can See For Miles - The Who
>
> Don't Worry Baby - Beach Boys