NashEquilibro NashEquilibro - 1 year ago 102
Jade Question

What is wrong with this javascript date conversion in a jade template?

I am using this in my jade template:
- function convertDate(dateString) {var date = new Date(dateString);return date.getDate()+"."+date.getMonth()+"."+date.getFullYear();}
| #{convertDate(}

while iterating over tiles.

For the input "2016-07-14" the return is "14.6.2016", for "2016-08-09" -> "9.7.2016" etc.

Why does a month get lost?

Answer Source

date.getMonth() returns the month index, which is 0-based.

To convert it to month position you need to add 1 to its value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download