Storing dates in to wix database from selected date in the datepicker. Before storing date using below function
function eventDateFormat(edate, etime) {
var YYYY = edate.getFullYear();
var M = edate.getMonth();
var D = edate.getDate();
// ADD a "TimePicker" control to your page
var HH = (etime.slice(0, 2));
var MM = etime.slice(3, 5);
var datetime = new Date(YYYY, M, D, HH, MM);
return datetime;
}
In the repeater displaying dates form the database (Format is like E.g:- May 30, 2020)using below function
function dateFormat (dateVal) {
var month = new Array();
month[0] = "Jan";
month[1] = "Feb";
month[2] = "Mar";
month[3] = "Apr";
month[4] = "May";
month[5] = "Jun";
month[6] = "Jul";
month[7] = "Aug";
month[8] = "Sep";
month[9] = "Oct";
month[10] = "Nov";
month[11] = "Dec";
let date = new Date(dateVal);
let day = date.getDate();
let mm = month[date.getMonth()];
let year = date.getFullYear();
let dateStr = mm + " " + day + ", " + year;
return dateStr;
}
But for india time it displays proper and for other location like US it is showing one day less(E.g:- In india → May 30, 2020, In US → May 29, 2020 and in database it is May 30, 2020 only).
How to fix this problem it should be same date for all location?