Reputation: 2719
I'm trying to do excel export using alasql and passing my date,12 Apr 2018 by transforming using below function
var dateStr = "12 Apr 2018";
function trandformDate(dateString){
var date = new Date(dateString);
return new Date(date.setDate(date.getDate() + 1));
}
var date = trandformDate(dateStr);
When the excel gets generated I was able to see the date in MM/DD/YYYY format with the timezone.I would like to keep the date and removw timezone from excel.Please let me know how can I send time without timezone to excel so that the format remains the same ie., MM/DD/YYYY
Upvotes: 0
Views: 984
Reputation: 97
Simply split the array by space, and then use only the first part of the array.
var date = new Date();
date = date.split(" ")[0];
Upvotes: 0
Reputation: 2719
Fixed by passing the date and setting timestamp to 0 using setUTC()
var dateStr = "12 Apr 2018";
transformDate(dateString) {
const date = new Date(dateString);
const timeStamp = new Date(date.setDate(date.getDate() + 1));
timeStamp.setUTCHours(0);
timeStamp.setUTCMinutes(0);
timeStamp.setMilliseconds(0);
return timeStamp;
}
var date = trandformDate(dateStr);
Upvotes: 2