0

Using node.js on a lambda in aws why does

const todaysDate = Date.now();

return todays date as '1513319707926'

I know the format is wrong but iv tried const todaysDate = Date.now().format('MM/DD/YYYY'); and that doesnt fire

all I want is todays date to equal for example 15/12/2017

Noel Llevares
  • 13,607
  • 2
  • 51
  • 79
John
  • 3,853
  • 20
  • 69
  • 146
  • 3
    Possible duplicate of [How do I get the current date in JavaScript?](https://stackoverflow.com/questions/1531093/how-do-i-get-the-current-date-in-javascript) – Arun Kumaresh Dec 15 '17 at 06:46

2 Answers2

2

Try,

const todaysDate =new Date();
console.log((todaysDate.getMonth()+1)+'/'+todaysDate.getDate()+'/'+todaysDate.getFullYear());
programtreasures
  • 4,202
  • 1
  • 9
  • 27
0

here what you want

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!

var yyyy = today.getFullYear();
if(dd<10){
    dd='0'+dd;
} 
if(mm<10){
    mm='0'+mm;
} 
var today = dd+'/'+mm+'/'+yyyy;
document.getElementById("demo").innerHTML = today;`
Rakesh Yadav
  • 87
  • 1
  • 5