Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <section id="app" class="container pt-5">
  <label for="">Enter a date</label>
  <input type="text" class="datepicker form-control" v-model="value" >  
  <hr />
  <p>Date is: {{ value }}</p>




                var app = new Vue({
  el: '#app',
  data: {
    value: '02/02/1988'

//var regex = /(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d/
//var regex = /^(0[1-9]|[12][0-9]|3[01])|(0[1-9]|1[012])/
var regex = /^(0[1-9]|1[012]|[1-12])(|\/|\.)(0[1-9]|[12][0-9]|3[01]|[1-9])(|\/|\.)(((19|20)\d\d)|(\d\d)$)/gm

function ExtractDate(date){
  if (typeof(date)==="object") return date;
  var a = regex.exec(date);
  if (!a) return;
  var mm = +a[1], dd = +a[3], yy = +a[5];
  mm = mm < 10 ? "0" + mm : mm; 
  dd = dd < 10 ? "0" + dd : dd;
  yy = yy.toString().length === 4 ? yy : 30 < yy && yy < 100 ? 1900+yy : 2000+yy

  return {
    mm: mm,
    dd: dd,
    yy: yy,
    date: new Date(+yy, (+mm - 1), (+dd) )
  format: {
     * Say our UI should display a week ahead,
     * but textbox should store the actual date.
     * This is useful if we need UI to select local dates,
     * but store in UTC
    toDisplay: function(date, format, language) {
      console.log('>' , date )
      if (typeof(date)==="object") {
        var mm = date.getMonth() + 1, dd =  date.getDate(), yy = date.getFullYear();
        mm = mm < 10 ? "0" + mm : mm; 
        dd = dd < 10 ? "0" + dd : dd;        
      console.log('>>', date, mm, dd, yy)
      return [mm, dd, yy].join("/");
      /*return date;
      var d = ExtractDate(date);
      console.log("toDisplay:", date, d, typeof(date));
      if (!d) return
      var result = [d.dd,, d.yy].join("\\")
      console.log("toDisplay:", d, result);
      return result; */
    toValue: function(date, format, language) {
      console.log('+', date)
      var d = ExtractDate(date)
      if (!d) return
      console.log("toValue:", d );