zero6pak avatar

Date Time Replacement In IFTTT with google script

zero6pak

Published: 31 Dec 2017 › Updated: 31 Dec 2017Date Time Replacement In IFTTT with google script

Date Time Replacement In IFTTT with google script

IFTTT is good macro tool.
But OccuredAt format is not compatible with google datetime.

=TIMEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " ")) + DATEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " "))
Above is not working.

So, I write new custom function.

function dtr(myDate){
var vv = myDate;

vv = vv.toString();

var va = vv.split(" at ");
if(va[1]==undefined){
return;
}
var ampm = va[1].split(":");

if(va[1].substr(-2)=="PM"){
myDate = new Date((va[0].replace(",","")+", "+(parseInt(ampm[0],10)+12)+":"+ampm[1].substr(0,2)+":00"));
}else{
myDate = new Date((va[0].replace(",","")+", "+parseInt(ampm[0],10)+":"+ampm[1].substr(0,2)+":00"));
}
return myDate;
}

s1.jpg

Create new script in spreadsheet.

s2.jpg

Save script.

And you edit your IFTTT

=dtr("{{OccurredAt}}")

s3.jpg

Check your Logs!

s4.jpg

Leave Date Time Replacement In IFTTT with google script to:

Written by

Read more #spreadsheet posts


Best Posts From zero6pak

We have not curated any of zero6pak's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From zero6pak