top | item 6046238

(no title)

flyinRyan | 12 years ago

>Yeah, I know: it's not Javascript that's broken, it's the DOM.

No, JavaScript itself is a ridiculous language. Every time I have to deal with it I grit my teeth. Right now I'm dealing with dates. Luckily JS has a built in Date class! Which, of course, does nearly nothing. If you call "getDay" you get a zero indexed number representing the day of the week. So since there's no formatting functions to print out dates, how do you get the month-day number? Oh, right, you call getDate...

If I didn't know better I would think this abomination were created by someone who thought the secret of PHP's success was being horribly defined.

discuss

order

dccoolgai|12 years ago

Try this: date.toLocaleDateString("en-US", {month: "numeric", day: "numeric"});

flyinRyan|12 years ago

I want a specific format to our proprietary systems. In C# I can just say "date.Format("dd.MM.YYYY")" or what ever I want.