I've convert the string to date using strptime:
time = (Date.strptime(f,("%m-%Y"))).strftime("%a, %d %b %Y")
convert_time = Date.strptime(time,("%a, %d %b %Y"))
p convert_time
First, I convert string 02-2015(f variable) to date, and then formatting it to "%a, %d %b %Y", after that, I convert it to date again. The final result that I want to get is the date with format like that: Sun, 01 Feb 2015(store by convert_time variable). I print convert_time and archive my goal(got Sun, 01 Feb 2015), but I didn't know why the console show me error: Argument Error (invalid date). Can someone tell me where I made mistake?
Aucun commentaire:
Enregistrer un commentaire