Mauro74 Mauro74 - 1 year ago 141
Javascript Question

moment js extract year from string

I'm new to moment.js and I can't really understand the documentation. I'd like to manipulate some dates in string format.

I have my date as string from json feed and looks like:

var year =
// it returns a string like "25/04/2012"

How do I extract the year from it using moment.js ?

Answer Source

You can use


in your example:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download