var valtgl = $("#val-tgl").val();
var dateori = new Date(valtgl);
I would like something like this:
Tuesday, 2 October 2018
instead of:
Tue Oct 02 2018 07:00:00 GMT+0700 (Waktu Indonesia Barat)
Any clue how to?
var valtgl = $("#val-tgl").val();
var dateori = new Date(valtgl);
I would like something like this:
Tuesday, 2 October 2018
instead of:
Tue Oct 02 2018 07:00:00 GMT+0700 (Waktu Indonesia Barat)
Any clue how to?
I'd just use toLocaleTimeString.
let options = {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'};
let now = new Date();
console.debug(now.toLocaleTimeString("en-GB", options));
If you need more formatting control then you could use a library like Fecha or moment.js where you can do stuff like this:
// in fecha
fecha.format(new Date(2015, 10, 20), 'dddd MMMM Do, YYYY');
// in moment
moment().format('MMMM Do YYYY, h:mm:ss a');
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.