How to convert 24.hours
into minutes it gives me second.
1.9.3p392 :076 > 24.hours
=> 86400 seconds
One NON-RUBY way is
1.9.3p392 :079 > 24*60
=> 1440
Is there any ruby or rails way of doing this? i.e. 24.hours_in_minutes
The most appropriate way to do this is probably:
24.hours / 1.minute
This way you keep the readability and clear intention of the 'ruby mindset'.
Of course, this will have a constant value so you should probably store it in an appropriately named constant (e.g. MINUTES_IN_A_DAY
) rather than calculating it every time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With