cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript example for date/time manipulation in script snap?

doug_fossler
New Contributor

I am attempting to write javascript for a script snap to manipulate dates, times, and date/times. I am having issues getting a date field plus a separate time field parsed as a DateTime and further having issues when I need to add a duration of time to the DateTime. Are there any examples of this somewhere?

Doug

13 REPLIES 13

punchInDate is in “yyyy-MM-dd”
punchInTime is in “HH:mm”

punchIn should be something like “MM/dd/yyyy HH:mm”, or “yyyy-MM-dd HH:mm”, or “MMddyyyyHHmm”, etc.

@doug.fossler
Use this-
$punchInDate.toLocaleDateString(‘{“format”:“yyyy-MM-dd HH:mm”}’

if punchInDate is coming as date field , if it’s coming as String then 1st do Date.parse($punchInDate), then use formater in mapper snap

I am not doing this inside a mapper snap, i am attempting to do this in javascript inside a script snap on purpose.

@doug.fossler

use mapper only. Why need to have script snap? always trying to ignore script as much as possible.

doug_fossler
New Contributor

My use case will not allow this to be handled in a mapper. Unless you can tell me how to edit multiple docs based on the prior edits of said docs? I am aware of array’s but they would not solve the problem.