0

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?

Vikrant
  • 4,922
  • 16
  • 46
  • 68
rajub
  • 272
  • 1
  • 4
  • 14
  • 1
    Possible 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 Answers3

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"

http://jsbin.com/zixacacuda/edit?js,console

Zulhilmi Zainudin
  • 7,985
  • 8
  • 44
  • 79
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
  • 434
  • 3
  • 10
0

var now = new Date().toLocaleDateString();

it willl retrun "12/28/2015 (MM/DD/YYYY)" format.

Raj
  • 321
  • 1
  • 4