cleave.js icon indicating copy to clipboard operation
cleave.js copied to clipboard

Can't simply format part of a date

Open vgjenks opened this issue 2 years ago • 1 comments

I'm having a hard time wrapping my head around how this is even formatting, without having looked at the Cleave source myself yet.

https://codepen.io/vinjenks/pen/PoEwXBd

The date I'm providing is legit: 2017-10-01. So, I'm racking my brains to get to "10/2017" but Cleave date doesn't seem to be able to handle that. The best I can seem to get it to do is backwards, e.g. "2017/10".

vgjenks avatar Mar 14 '22 21:03 vgjenks

Why not set the value="2017-10-01" backwards to match the format?

<input class="form-control cleave-input-date" placeholder="DD-MM-YYYY" value="10-10-2010">
var cleave = new Cleave('.cleave-input-date', {
    date: true,
    delimter: '-',
    datePattern: ['d','m','Y']
});

https://codepen.io/DanEnglishby/pen/ywXjEx Look around for the examples: the order of the format (d,m,Y) and (dd-mm-yyyy)value specified in cleave.js are the same.

wafflook avatar Mar 18 '22 02:03 wafflook