dotty
dotty

Reputation: 41433

JS date converting

Hay, how can i turn a string like "04 Jan 2010" into a string like "1/4/2010". Can i do this with the JS date object?

Thanks

Upvotes: 1

Views: 260

Answers (3)

sean1093
sean1093

Reputation: 109

You can try this: timeSolver.js

var dateString = timeSolver.getString("04 Jan 2010", "MM/DD/YYYY");

You can get date string by using this method:

getString(date, format)

Hope this will help you!

Upvotes: 0

InterfaceGuy
InterfaceGuy

Reputation: 139

The JavaScript function getYear() is deprecated. You should use getFullYear() instead.

Upvotes: 0

Peter
Peter

Reputation: 6362

Perhaps Date.parse() is what you're looking for?

If that doesn't do it, then Datejs adds more robust parsing.

Upvotes: 3

Related Questions