Say, i have below information:
Asia zone, current date say 7/23/2018 and time say 2.25 pm.
With these three values, i want to generate timestamp number like 90001333... is that possible? in javascript or C#
Say, i have below information:
Asia zone, current date say 7/23/2018 and time say 2.25 pm.
With these three values, i want to generate timestamp number like 90001333... is that possible? in javascript or C#
Use following:
var time = '2.25 pm'
var date = new Date('7/23/2018');
var isPm = time.indexOf('pm') != -1;
time = time.replace(/pm/g, '');
time = time.replace(/am/g, '');
var spl = time.split(".");
date.setHours(isPm ? 12 + Number(spl[0]) : spl[0], spl[1], 0);
var st = date.toLocaleString('en-US', {
timeZone: 'Asia/Kolkata'
});
var timestamp = Number(new Date(st));
console.log(new Date(st))
console.log(timestamp)
You can use the above logic to complete the quest.
If you want plain and unreliable in some cases JS:
var unixTime = Date.parse("7/23/2018 02:25:00 GMT+8")
or with Moment.js
var date = moment("2016-10-11 18:06:03").tz("Asia/Bangkok").format();
var unixTime = moment(date).format("X");