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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.