i want to change Local time to UTC and vice-versa, by taking users date value.(User will choose the dateand Time and according to dates it will change to UTC and vice versa )
Can someone help on this
i want to change Local time to UTC and vice-versa, by taking users date value.(User will choose the dateand Time and according to dates it will change to UTC and vice versa )
Can someone help on this
You can try this:
function calculateTimestamp(date) {
    date = date.split('-');
    var year = date[2];
    var month = date[1];
    var day = date[0];
    var d1 = new Date(Date.UTC(2017, 9, 1, 17, 0, 0, 0)); //It is static time based upon you will count time in ms
    var d2 = new Date(Date.UTC(year, (month - 1), day, 17, 0, 0, 0));
    return parseInt((d2.getTime() - d1.getTime()) / 1000);
}
var startDate = '27-02-2018';
var startTime = calculateTimestamp(startDate);
Now you can convert this timestamp again as below:
var d = new Date(Date.UTC(2017, 9, 1, 17, 0, 0, 0));
var t = parseInt(d.getTime() / 1000);
var d = new Date((startTime + t) * 1000);