Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

google apps script moment js

function testMoment() {
  eval(UrlFetchApp.fetch('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js').getContentText());
  var date = moment().format("MMM Do YY");
  Logger.log(date)
}
Comment

google apps script moment js

var cacheExpire = 3600;
var momentCache = "momentCache";
var momentUrl = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js"

var momentTzCache = "momentTzCache";
var momentTzUrl = "https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.16/moment-timezone-with-data-2012-2022.min.js"

useCachedOrLive(momentCache,momentUrl);
useCachedOrLive(momentTzCache,momentTzUrl);

function useCachedOrLive(cacheToCheck, url){

  var cache = CacheService.getUserCache();
  var cachedData = cache.get(cacheToCheck);
  console.log(cacheToCheck);
  if(cachedData !== null){
    console.log("using cached " + cacheToCheck)
    eval(cachedData);
  }
  else
  {
    console.log("getting live " + cacheToCheck);
    var response = UrlFetchApp.fetch(url).getContentText();
    cache.put(cacheToCheck, response, cacheExpire);
    eval(response);

  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: postman scripts check variable exists 
Javascript :: server error payload too large base64 image 
Javascript :: javascript enumerate 
Javascript :: __dirname go back one directory 
Javascript :: chart.js change font color 
Javascript :: angular pipe json error 
Javascript :: vscode tab size 
Javascript :: chartjs line disable shadow 
Javascript :: react slick slider duplicate items when infinite true #1623 
Javascript :: pipefy api search card field 
Javascript :: newtonsoft json deserialize c# example 
Javascript :: button disabled angular 
Javascript :: react native rename package name 
Javascript :: set html attribute jquery 
Javascript :: SyntaxError: Cannot use import statement outside a module node js 
Javascript :: capture enter button react input 
Javascript :: js iterate array index 
Javascript :: htmlparser2 extract text from html 
Javascript :: js sort by array key value 
Javascript :: socket io get ip 
Javascript :: enable network request in react native 
Javascript :: javascript change table row color based on value 
Javascript :: valid json return null on json_decode 
Javascript :: fancybox 2 image counter 
Javascript :: drupal 8 node has field 
Javascript :: codemirror get value 
Javascript :: check if somethin exist in an object js 
Javascript :: discord bot javascript remove user data in array 
Javascript :: rails is not defined javascript 
Javascript :: how to get dynamically generated id in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =