简体   繁体   中英

Using Regular Expression and Jquery to Manipulate Date Field

I'm hoping someone can help me with the targeting the date from a post

from this "Wed, 27 Feb 2013 09:00:00 +1100"

to this

         <span class="day">27</span>
         <span class="month">Feb</span>

Ignoring the year and time. The idea is that I can then style the day and month so it sits to the left of the title.

Class day and month can then sit inside a parent div with a darkish background like so 1 http://www.canberra.edu.au/media/test/date.jpg

I'm guessing something like this?

 $("h6").html(function(index, old) {
   return old.replace(some regular expression/, '<span class="day">$1</span><span class="month>$2</span>"');
 });

Thanks in advance

var matches = /^.{3}, (\d+) (.{3}) \d+/.exec("Wed, 27 Feb 2013 09:00:00 +1100")

// matches[1] --> "27"
// matches[2] --> "Feb" 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM