Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <title>Foo</title>
  3. <div>Expected value: <b>2011-06-03 02:33:54</b></div>
  4. <div>Actual value: <b id="ret"></b></div>
  5. <script>
  6.   var formatDate = function(d,f){return f.replace(/{(.+?)(?::(.*?))?}/g,function(v,c,p){for(v=d["get"+c]()+/h/.test(c)+"";v.length<p;v=0+v);return v})};
  7.  
  8.   document.getElementById( "ret" ).innerHTML = formatDate(
  9.     new Date(2011, 5, 3, 2, 33, 54, 0),
  10.     "{FullYear}-{Month:2}-{Date:2} {Hours:2}:{Minutes:2}:{Seconds:2}"
  11.   );
  12. </script>