Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.mattkruse.com/" rel="nofollow noreferrer">Matt Kruse</a> developed a <a href="http://mattkruse.com/javascript/date/date.js" rel="nofollow noreferrer">really interesting date library</a> which should help with your particular case. </p> <p>Here's a snippet of the method you should use for the issue you mentioned:</p> <pre><code>// ------------------------------------------------------------------ // parseDate( date_string [, prefer_euro_format] ) // // This function takes a date string and tries to match it to a // number of possible date formats to get the value. It will try to // match against the following international formats, in this order: // y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d // M/d/y M-d-y M.d.y MMM-d M/d M-d // d/M/y d-M-y d.M.y d-MMM d/M d-M // A second argument may be passed to instruct the method to search // for formats like d/M/y (european format) before M/d/y (American). // Returns a Date object or null if no patterns match. // ------------------------------------------------------------------ function parseDate(val) { var preferEuro=(arguments.length==2)?arguments[1]:false; generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d'); monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d'); dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M'); var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst'); var d=null; for (var i=0; i&lt;checkList.length; i++) { var l=window[checkList[i]]; for (var j=0; j&lt;l.length; j++) { d=getDateFromFormat(val,l[j]); if (d!=0) { return new Date(d); } } } return null; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload