3

How would I get the current date to display in jquery as "Saturday, October 31, 2015"? I can only find how to get the date to display as "dd/mm/yyyy"

Maduro
  • 713
  • 5
  • 23
  • 44
jogx
  • 75
  • 8

3 Answers3

2

To get 31/10/2015 use this :

// "31/10/2015" and august : 31/08/2015 :
var a=new Date();
alert([("0" + a.getDate()).slice(-2), ("0" + (a.getMonth()+1)).slice(-2), a.getFullYear()].join("/"));

// "31/10/2015" and august : 31/8/2015 :
[a.getDate(), (a.getMonth() + 1), a.getFullYear()].join("/"); 

Example :

function getDate() {
  var a=new Date();
  return [("0" + a.getDate()).slice(-2), ("0" + (a.getMonth() + 1)).slice(-2), a.getFullYear()].join("/");
}


document.write(getDate());
user2226755
  • 12,494
  • 5
  • 50
  • 73
  • 3
    She ask for `Thursday, October 31, 2015` not `31/09/2015` and the current date is `31/10/2015` =) – Maduro Oct 31 '15 at 15:27
1

To get Sat Oct 31 2015 use this:

var TodaysDate = new Date().toDateString();

JsFiddle

gizmo
  • 82
  • 1
  • 5
1

You can:

var date = new Date();

var str = ["Sunday", "mon", "tues", "wed", "thurs", "fri", "sat", "sun"][date.getDay()];
str += ", " + ["jan", "feb", "mar", "apr", "may", "june", "jul", "aug", "sep", "oct", "November", "dec"][date.getMonth()];
str += " "  + date.getDate();
str += ", " + date.getFullYear();

console.log(str);

Sunday, November 1, 2015

Alex K.
  • 171,639
  • 30
  • 264
  • 288