I use this code to generate date:
DateTime.strptime("10/26/2015 07:09:52 AM", '%m/%d/%Y %I:%M:%S %p')
But when I use this code to generate random date:
(Time.now - rand(15552000)).strftime('%m/%d/%Y %I:%M:%S %p')
I get error:
undefined method `to_date' for nil:NilClass
Can you give some solution how I can fix this?
Aucun commentaire:
Enregistrer un commentaire