Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Converting hours to days, hours, minutes

Avatar

Avatar
Level 1
Daniel_Claire
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
Daniel_Claire
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile
Daniel_Claire
Level 1

18-02-2020

Probably a simple script for some of you veterans, but as a rookie, I’m stumped. Could someone help with converting hours to days, hours and minutes (e.g., 619 hours = xx days, xx hours and xx minutes)? FormCalc or Javascript. Thanx in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
Nirmal_Jose
MVP

Likes

118 likes

Total Posts

207 posts

Correct Reply

58 solutions
Top badges earned
Validate 1
Establish
Coach
Contributor
Shape 1
View profile

Avatar
Validate 1
MVP
Nirmal_Jose
MVP

Likes

118 likes

Total Posts

207 posts

Correct Reply

58 solutions
Top badges earned
Validate 1
Establish
Coach
Contributor
Shape 1
View profile
Nirmal_Jose
MVP

20-02-2020

I know its a slight overkill and may not support your exact requirement, but AEM has an OOTB library that can help you with any date conversion. - moment.js

Moment JS can be found at [1], category name 'moment'

You can use various conversions as mentioned in [2]

 

[1] - /libs/clientlibs/granite/moment 

[2] - https://momentjs.com/docs/#/get-set/minute/

Answers (1)

Answers (1)

Avatar

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

155 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

155 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile
Suraj_Kamdi
MVP

18-02-2020

@Daniel_Claire If I am correct... You can try with following js code

 

var days = Math.floor(providedHrs/24);
var remainder = providedHrs % 24;
var hrs = Math.floor(remainder);
var min = Math.floor(60*(remainder-hrs));

 

Hope this will help you to solve your query...😀