1

I am having one google sheet which contains date. While fetching it, it shows 7/4/2018 as 43285 in javascript.

I want to show date as it is. How can I do it?

Thank you, Trupti

Trupti
  • 609
  • 1
  • 9
  • 21

1 Answers1

1

Use the javascript Date Object to work with time then use the snippets from this SO post

function convertEpochToSpecificTimezone(offset){
    var d = new Date(1495159447834);
    var utc = d.getTime() + (d.getTimezoneOffset() * 60000);  //This converts to UTC 00:00
    var nd = new Date(utc + (3600000*offset));
    return nd.toLocaleString();
}

and this SO post as code reference.

var now = new Date(); 
var now_utc =  Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),
 date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());

 return new Date(now_utc);
noogui
  • 16,300
  • 4
  • 25
  • 51