Thank you everyone for the responses
bjorsq your solution worked out great. Thank you for the help.


On Feb 4, 5:39 pm, bjorsq <p...@bjorsq.net> wrote:
> To do this in JavaScript, you need to extract the text representation of the
> date you have in the div, parse it, and set up a new JavaScript Date object
> to compare against the current date/time. If your dates are formatted like
> [day]/[month]/[year] (I'm in the UK), then this should work (but will need
> some error checking in it to cope with blank or malformed dates):
>
> $(document).ready(function() {
>   var now = new Date();
>   $('td.yui-dt0-col-LastActivity div').each(function() {
>     var divdate = new Date();
>     /* split the text date in the div */
>     var dateparts = $(this).text().split('/');
>     /* set the properties of the Date object
>      *for US format dates [month]/[day]/[year] the array indexes for months
> and days need switching
>      */
>     divdate.setDate(parseInt(dateparts[0]));
>     /* months are zero indexed! */
>     divdate.setMonth((parseInt(dateparts[1])-1));
>     divdate.setYear(parseInt(dateparts[2]));
>     /* compare dates - 14 days = (14*24*60*60*1000) milliseconds */
>     if (divdate.getTime() > (now.getTime() - (14*24*60*60*1000))) {
>       $(this).addClass('highlight');
>     }
>   });
>
>
>
> });
> Bob O-2 wrote:
>
> > Can any one point me in the right direction for my issue.
>
> > I have a div with a text value pulled in from a database 01/01/2009
>
> > Im trying to write a javascript that can take that value and compare
> > it against new Date();
>
> > $(document).ready(function() {
> >   now = new Date();
> >   lastActivityDivs = $('td.yui-dt0-col-LastActivity div');
> >   lastActivityDivs.each(function() {
> >    if ($(this).val() == (now < 14)) {
> >    $(this).addClass('.highlight');
> > }
> >   });
> > });
>
> > i know this isnt correct, but it gives you an idea of what im trying
> > to accomplish..
>
> > Any help would be great.
>
> > Thank you
>
> --
> View this message in 
> context:http://www.nabble.com/Dealing-with-Date-Comparison-tp21841297s27240p2...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to