标签云

微信群

扫码加入我们

WeChat QR Code

This question already has an answer here:Detecting an “invalid date” Date instance in JavaScript40 answersI want to know if I can create a function that can read a variable and if it's a date convert it to dd/mm/yyyy and when it's not a date it must do nothingThe date is in this format 2011-11-16T16:48:34.743In my case i do have this code : (I have to read colomns name and if is egal then i take the value of the variable the problem is that when it take date i can format it )if (type == "TASK") {for (var key in ticket.task) {if (key == result) {Val = Val.replace(item, ticket.task[key]);}}}i have to replace a word with a value in the scope ticket.task[key]the method match doesn't work with ticket.task[key]


Yes you can (as phylax proved even if a wrong date won't throw any exception) but...did you try something? At least a Google search?

2019年06月25日00分13秒

Konstantin D - Infragistics i tried the the answer that you show me but i doesn't work

2019年06月26日00分13秒

no, new Date(s) won't throw any exception for an invalid date.

2019年06月25日00分13秒

uups i tried it in the console and misunderstood the results.

2019年06月26日00分13秒