Removing last 9 characters from a string and then reformatting the remaining date characters
My question has 2 parts. First I would like to remove the last 9 characters from a generated string using jQuery eg
2011-04-04T15:05:54
which would then leave the date remaining. I开发者_开发问答 know to use the .substring function. After the time is removed I need to reformat the date into this format
08.04.11 (for eg)
I am learning how to write jQuery and would appreciate any help with this code.
This is what you do with pure javascript, jQuery is not needed.
var d1=new Date();
d1.toString('yyyy-MM-dd'); //returns "2009-06-29"
d1.toString('dddd, MMMM ,yyyy') //returns "Monday, June 29,2009"
Another example to fit your case:
var d1=new Date();
d1.toString('dd.MM.yy'); //returns "08.04.11"
More:
Where can I find documentation on formatting a date in JavaScript?
精彩评论