title: Get the given date format (the string specifying the format) in javascript or momentjs
body: <p>Given a datestring, how can I get the format string describing that datestring?</p>
  
  <p>Put another way, how can I get the format string that Date() or MomentJS (might be different for each, that's fine) would use to parse that datestring if one didn't pass an explicit format to use?</p>
  
  <p>So given <code>'2016-01-01'</code> it should output something like <code>'YYYY-MM-DD'</code>, for example.</p>
  
  <p>(I am aware this is a simple question and may have an answer somewhere, but it is difficult to word concisely, so I could only find questions and answers about how to parse datestrings or how to display dates. None about how to output the <em>format</em> itself.)</p>