我有一个类似于这个“%d-%m-%Y”的日期格式,我需要将此格式传递给Datepicker,但据我所知,Datepicker不允许这种格式。 由于这种格式是由用户引入的,我无法预测将引入哪种格式。
我只有momentjs,jquery,下划线和datepicker来处理这个因为我正在工作的系统是非常严格的(他们不允许我安装新的插件)
MomentJS返回一个Date对象,它不会转换其中的格式字符串,因此我无法检索它或将其解压缩以在datepicker dateformat中使用它。
有没有办法将此unix格式传递给datepicker,或者将类似的字符串转换为“%d-%m-%Y”到“dd-mm-YY”
订单可以是“%Y-%m-%d”的任何内容,也可以是“%Y”的一部分
编辑1:
为了更好地澄清这一点,我需要将此字符串“%d-%m-%Y”转换为此“DD-MM-YYYY”,但符号可以是任何顺序,还有其他符号:
%a%A%b%B%c%d%H%I%j%m%M%p%S%U%W%w%x%X%y%Y%Z %%
I have a dateformat like this one "%d-%m-%Y" and I need to pass this format to Datepicker, but the Datepicker does not allow this format as far as I'm aware. Since this format is introduced by the user, I can not predict wich format will be introduced.
I only have momentjs, jquery, underscore and datepicker to handle this because the system I'm working is quite restrictive (they do not allow me to install new plugins)
MomentJS returns a Date Object, and it does not convert the format string inside it, so I can't retrieve it or extract it to use it in the datepicker dateformat.
Is there a way to pass this unix format to datepicker, or to convert similar strings like this one "%d-%m-%Y" to "dd-mm-YY"
The order could be anything from this "%Y-%m-%d" or just one part of it "%Y"
Edit 1:
To clarify this better, I need to convert from this string "%d-%m-%Y" to this one "DD-MM-YYYY" but the symbols could be in any order, and there are also other symbols:
%a %A %b %B %c %d %H %I %j %m %M %p %S %U %W %w %x %X %y %Y %Z %%
最满意答案
您可以使用moment-strftime插件 ,该插件以该格式了解令牌。
You can use the moment-strftime plugin, which understands tokens in that format.
更多推荐
发布评论