Having trouble with this:
var now = new Date();
var timestamp = now.format("dd/mm/yyyy HH:MM:ss") + " (" + GetLoggedUserName() + ")";
I get: Object doesn't support property or method 'format'
I was sure this worked before though on other projects..
There is no native format in JavaScript for” dd-mmm-yyyy”. To get the date format “dd-mmm-yyyy”, we are going to use regular expression in JavaScript. The regular expression in JavaScript is used to find the pattern in a string. So we are going to find the “dd-mmm-yyyy” pattern in the string using match() method.
The format()
function is not standard for Date
objects in javascript.
You have most likely seen this in an application running a date formatting library such as moment.js.
http://momentjs.com/
moment().format('MMMM Do YYYY, h:mm:ss a');
Your example could be rewrote in moment.js like this:
var timestamp = moment().format("DD/MM/YYYY HH:mm:ss") + " (" + GetLoggedUserName() + ")";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With