N
N
Ninja Mate2016-02-22 16:09:17
JavaScript
Ninja Mate, 2016-02-22 16:09:17

How to get today's number in React JS?

How do you get today's Date.now() number in React in this format '11-11-1998'?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Deodatuss, 2016-02-22
@victorzadorozhnyy

var dateNow = new Date();
var timeString = (dateNow.getDate()<10?'0'+dateNow.getDate():dateNow.getDate())+'-'+(dateNow.getMonth()+1<10?'0'+(dateNow.getMonth()+1):dateNow.getMonth()+1)+'-'+dateNow.getFullYear();

A
Anton Izmailov, 2016-02-22
@WapGeaR

Connect moment.js and use it, everything is simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question