Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Time Calculations. PLEASE HELP

Avatar

Former Community Member
Does anyone have some quick tips on how to calculate time - I have managed successufully to calculate the time but I'm having a hard time deducting another field (lunch hour).



????
3 Replies

Avatar

Former Community Member
You basically will need an understanding of the Date() object in the JavaScript model.



Some methods:



getDate() - day of the month

getDay() - day of the week

getHours() - hour (0-23)

getMinutes() - minutes

getSeconds() - seconds

getMonth() - month (0-11)

getYear() - year

getTime() - time in full format



To produce today's date:

var today_date= new Date()

var myyear=today_date.getYear()

var mymonth=today_date.getMonth()+1

var mytoday=today_date.getDate()



document.write("Today's date is: ")

document.write(myyear+"-"+mymonth+"-"+mytoday)

Avatar

Former Community Member
I was hoping for FormCalc references - any ideas??

Avatar

Level 1

hello,

How do you calculate time? what i whant is, that 01.30 + 01.30 = 03.00 ( not 2.60)

can you help me ?