Date Time Replacement In IFTTT with google script

in #spreadsheet7 years ago

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

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 58445.95
ETH 2616.08
USDT 1.00
SBD 2.41