I want is, the formatted string as, MM/DD/YY
or DD/MM/YYYY
.
Which of these is set by client in his/her system.
How to get it?
Asked
Active
Viewed 255 times
0
-
1Possible duplicate of [Where can I find documentation on formatting a date in JavaScript?](http://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript) – Peter Uhnak Dec 28 '15 at 10:22
-
Also duplicate of https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date – Peter Uhnak Dec 28 '15 at 10:22
-
What do you mean by `get client time format`? Provide some example. – Olga Dec 28 '15 at 10:56
3 Answers
0
var date = new Date();
var day = date.getDay();
var month = date.getMonth();
var year = date.getFullYear();
var final = day + "/" + month + "/" + year;
console.log(final); // "1/11/2015"

Zulhilmi Zainudin
- 9,017
- 12
- 62
- 98
0
var dt=new Date('2015-12-12');
var d=dt.getDay();
var m=dt.getMonth();
var y=dt.getFullYear();
var dtformated=d+'/'+m+'/'+y
console.log(dtformated)

kishan
- 454
- 3
- 10
0
var now = new Date().toLocaleDateString();
it willl retrun "12/28/2015 (MM/DD/YYYY)" format.

Raj
- 321
- 1
- 4