I need to create a javascript checkDateFormat
function which takes two string arguments:
- Date string
- Format string
It should check whether the date string is correctly formatted based on the format string.
For example:
checkDateFormat("12-32-2012", "dd-MM-yyyy") // false
The user may change the format string and I need to check the date accordingly.
I have searched a lot but couldn't find a generic function that achieves what I need. Is this achievable or is it necessary to write different implementations for all the possible date formats ?
Thank you.
Maybe this does what you want?