Best answer

Convert minutes to hh:mm:ss with code

  • 18 November 2021
  • 5 replies
  • 970 views

Userlevel 1

Hello,

 

I have a field coming from an app expressed in minutes and needs to format it into an hh:mm:ss format.

I could not find that option in date/time formatter so I’m trying with a Code by Zapier step.

I want a value such as 60 to become 01:00:00 or let’s say 90 would become 01:30:00, etc...

 

I have no preference for python or JS, whichever one works will do,

 

Looking forward to reading your ideas.

Cheers,

Thomas

icon

Best answer by Troy Tessalone 19 November 2021, 04:39

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 7
Badge +11

Welcome to the Community, @Thomas2M!

I’m not 100% sure what code you’d need to use in order to convert the time into hh:mm:ss but it should be possible to select that format using a Formatter (Date / Time > Format) step.

As hh:mm:ss is a custom format you’d want to select the Custom value option and then type in the desired format directly into the To Format field. For example: 

e9cd2cd807c4fc65d5309eef45ef7809.png

You can find out more about using Formatter to adjust date/time formats here: Modify date and time formats in Zaps

Hope that helps! :)

Userlevel 1

Hi @SamB ,

 

How do you suggest I set the formatter date/time action for my particular requirement?

I tried a few options but no luck. The below set up returns “12:00:00” when I want 1:00:00 or 01:00:00

 

Let me know your thoughts.

 

Cheers

Userlevel 7
Badge +14

Hi @Thomas2M 

Try this JavaScript Code

 

Userlevel 1

Hello @Troy Tessalone ,

 

Thank you for chiming in, your code works beautifully :relaxed:

 

Appreciate the help

 

Cheers

Userlevel 7
Badge +11

Ah I see! Sorry for leading you down the wrong path there, @Thomas2M. You’re quite right, it does appear that it won’t do a straight conversion from minutes into hours. :(

I’m so glad you’ve since been able to get this sorted. Nice work here, @Troy Tessalone! :)