Salvatore Fucito
Salvatore Fucito

Reputation: 355

Convert date from local timezone?

The question is simple, I use momentjs to get the current date of the system, in particular this is the date returned:

Sun Jan 03 2016 17:17:00 GMT+0100 (ora solare Europa occidentale)

I want convert this date in this format like this:

03/01/2016 17:17:00

How I can achieve this?

This is my code:

moment(new Date()).toDate()

Upvotes: 2

Views: 60

Answers (1)

Daniel Bank
Daniel Bank

Reputation: 3909

You can use momentjs's format() function to format the date. As an example:

moment.locale('it');
moment(new Date()).format('dddd MM/DD/YYYY h:mm:ss');

This returns the date as "Domenica 01/03/2016 10:17:49"

Upvotes: 2

Related Questions