Formatting the Date in JavaScript

前端 未结 6 1680
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 06:54

Using newDate() function in Java script, I am able to get today\'s date. I am getting the date in the format 3/3/2009 (d/m/yyyy). But i actually need the date in the format

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 07:09

    You usually have to write your own function to handle the formatting of the date as javascript doesn't include nice methods to format dates in user defined ways. You can find some nice pieces of code on the net as this has been done to death, try this:

    http://blog.stevenlevithan.com/archives/date-time-format

    Edit: The above code seems to be really nice, and installs a cool 'format' method via the date object's prototype. I would use that one.

提交回复
热议问题