-1

Issue is that I have one value that is returned by

$(this).attr("ows_Modified"); //(Sharepoint and SPService thing)

This value seems to be string 'Fri Oct 19 2012 13:35:45 GMT+0200' need to compare it to the date object with value format like this:

var myDate = new Date();
myDate.setDate(myDate.getDate()-31);
//2012-10-19 12:14:13 

and check with one is newer. Any ideas how to do this please ?

gdoron
  • 147,333
  • 58
  • 291
  • 367
user13069
  • 5
  • 1
  • *"I'm not JS dev and have one time task."* If you're not a JS developer, then perhaps you should hire one for your one-time task. – I Hate Lazy Nov 19 '12 at 16:14
  • 1
    ...I guess why would you do that when someone will do your task for you for free? People really need to stop answering these questions. – I Hate Lazy Nov 19 '12 at 16:25

2 Answers2

1
var isBigger = new Date($(this).attr("ows_Modified")) > new Date().getDate()-31;
gdoron
  • 147,333
  • 58
  • 291
  • 367
1

Parse both dates with Date.js, it will understand both formats and then you can compare them.

After importing the library you can use

date1 = Date.parse(Fri Oct 19 2012 13:35:45 GMT+0200);
date2 = Date.parse(2012-10-19 12:14:13); // or whatever date
isGreater = date1.isAfter(date2);

As gdoron stated, you don't need date.js, but it may be worth taking a look, especially if you are likely to manage weird looking date formats or make tricky operations.

alemangui
  • 3,571
  • 22
  • 33