Inputmask: How to change datetime to yyyy-mm-dd h:s

Created on 10 Nov 2014  路  10Comments  路  Source: RobinHerbots/Inputmask

i want to change datetime format with 'yyyy-mm-dd h:s'

int date.extensions.js i changed
mask: "1/2/y h:s", placeholder: "dd/mm/yyyy hh:mm", alias: "dd/mm/yyyy",
to
mask: "y-1-2 h:s", placeholder: "yyyy-mm-dd hh:mm", leapday: "-02-29", separator: "-", alias: "yyyy/mm/dd",

then input "2021-02-dd hh:mm", the dd not works

Dates

Most helpful comment

@RobinHerbots
"h:s" part is not editable in input field in your fiddle example.
Could you hint how to fix that?

All 10 comments

@beneo ,

The latest commit fixes this. see #703

How come the day and the month is inverted when I do this :

$("input").inputmask("datetime", {
    mask: "y-1-2 h:s", 
    placeholder: "yyyy-mm-dd hh:mm", 
    leapday: "-02-29", 
    separator: "-", 
    alias: "yyyy/mm/dd"
  });

See jsFiddle : https://jsfiddle.net/fpoirier1/53nomjyb/

Have a look at the alias yyyy/mm/dd which inhrrits from mm/dd/yyyy

Anyway the datetime alias wil be rewritten tot accept a dateformat

I did have look but I still don't understand what I am missing here.

@fpoirier1 ,

You need to omit the datetime Datetime maps day to 1 and month to 2 and alias yyyy/mm/dd does the inverse due to his inheritance od mm/dd/yyyy. Have a look at the updated fiddle.

https://jsfiddle.net/53nomjyb/3/

In milstone 3.4 the datetime alias will deal with all formats.

@RobinHerbots
"h:s" part is not editable in input field in your fiddle example.
Could you hint how to fix that?

@denis-chmel
this occour because the alias attribute is defined with just date and not horary, you may change to alias: 'yyyy/mm/dd hh:mm'

@euricovidal can you please explain what is the format that is provided in the mask: "1-2-y h:s", , it certainly isn't a regex, and i am unable to understand how is this expression "1-2-y h:s" interpreted?

@denis-chmel @buttflattery
I tried some examples and i got some configs that work with date and time validation.
My fiddle:
$('input').inputmask({ mask: "y-2-1 h:s", placeholder: "yyyy-mm-dd hh:mm", separator: "-", alias: "datetime" });

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kolyabokov picture kolyabokov  路  5Comments

toxpal picture toxpal  路  6Comments

richard-flosi picture richard-flosi  路  3Comments

SujayKrishna picture SujayKrishna  路  7Comments

hrolick-git picture hrolick-git  路  5Comments