TimeSpan .getHours()

123 views
Skip to first unread message

Rodeoclash

unread,
Nov 11, 2009, 7:44:59 PM11/11/09
to Datejs - A JavaScript Date Library
Is it possible to return hours in a decimal format?

I have half our increments for a time picker, eg:

9:00am
9:30am
10:00am

and a finish time, I'd like to display a decimal hours next to each:

9:30am (0.5 hours)
10:00am (1 hours)
10:30am (1.5 hours)

at the moment I'm getting something like:

9:30am (1 hours)
10:00am (1 hours)
10:30am (2 hours)

I'll admit I'm about to give into the time.js file now, but I thought
their might be a hidden format option for this method.

Sam

Rodeoclash

unread,
Nov 11, 2009, 8:04:22 PM11/11/09
to Datejs - A JavaScript Date Library
Ahh. Looks like you can call toString on the TimeSpan object. Calling

toString('H:mm')

has done the trick!

Thanks for an awesome library guys!
Reply all
Reply to author
Forward
0 new messages