javascript get the day of the month code example

Example 1: Javascript get month name

var  months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date();
var monthName=months[d.getMonth()]; // "July" (or current month)

Example 2: javascript get current day of month

new Date().getDate();//gets day of month (1-31)

Example 3: js get day month year

const d = new Date();

d.getMonth() + 1;	// Month	[mm]	(1 - 12)
d.getDate();		// Day		[dd]	(1 - 31)
d.getFullYear();	// Year		[yyyy]

Example 4: how to get date time day year in javscript

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();

Tags:

Php Example