1

var date = new Date();//Mon Mar 15 2010 12:40:05 GMT+0300 (MSK) var omg = date.getDate() + 19;// 34 date.setDate(omg); document.write(date.toLocaleString()); //Sat 03 Apr 2010 12:43:00 PM MSK

How do I echo the values 3 (ie: day of month), 4 (April) and the current year?

alert(day); // Need 3
alert(month); // Need 4

Thank you

1
  • Please refer to W3 Schools documentation on this. Commented Mar 15, 2010 at 9:55

2 Answers 2

3

Year: date.getFullYear(). Month: date.getMonth(). Date: date.getDate().

Take a look at the reference at MDC.

Sign up to request clarification or add additional context in comments.

Comments

2
date.getDate();

date.getMonth() + 1

date.getFullYear()

If you want to get the date according to universal time then

date.getUTCDate();

date.getUTCMonth() + 1

date.getUTCFullYear()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.