How to convert the following 1. 7. 2015 16:25 into date and time format using javascript?
In the below mentioned image how to convert the these two values in to datetime with the following pattern
Day.month.year Hour:minute:second;
How to convert the following 1. 7. 2015 16:25 into date and time format using javascript?
In the below mentioned image how to convert the these two values in to datetime with the following pattern
Day.month.year Hour:minute:second;
Use moment JS https://momentjs.com/
function momentTest() {
var varDate = "2018-01-19 18:05:01.423";
var myDate = moment(varDate,"YYYY-MM-DD").format("DD-MM-YYYY");
var todayDate = moment().format("DD-MM-YYYY");
var yesterdayDate = moment().subtract(1, 'days').format("DD-MM-YYYY");
var tomorrowDate = moment().add(1, 'days').format("DD-MM-YYYY");
alert(todayDate);
if (myDate == todayDate) {
alert("date is today");
} else if (myDate == yesterdayDate) {
alert("date is yesterday");
} else if (myDate == tomorrowDate) {
alert("date is tomorrow");
} else {
alert("It's not today, tomorrow or yesterday!");
}
}
function toTimeZone(time, zone) {
var format = 'YYYY/MM/DD HH:mm:ss ZZ';
return moment(time, format).tz(zone).format(format);
}
this works only if you're using moment.js.