0

I'm trying to parse "Time Left To Buy" from a Groupon clone. Don't worry, everything is legal. The Javascript looks like

var untilDate = new Date(1316206740000);
        $("#wlt-DealTimeLeft .timer").countdown({until: untilDate,
        layout: "<div class='timerDiv withDay clearfix'><div class='countdownItem days'><p>{dn}</p>{dl}</div><div class='countdownItem'><p>{hn}</p>{hl}</div><div class='countdownSep'>:</div><div class='countdownItem'><p>{mn}</p>{ml}</div><div class='countdownSep'>:</div><div class='countdownItem'><p>{sn}</p>{sl}</div></div>", onTick: function(periods){
            $("#wlt-DealTimeLeft").uTimeLeftTick(periods,259080);
        }});

I was thinking about the Date value, but it isn't only regular unix timestamp. How can I get the date when the deal ends? It's some kind of jQuery countdown plugin. Thank you for any hints or advices.

KafkaM
  • 15
  • 3
  • Isn't the date when the deal ends `untilDate`? And aren't you setting that? Maybe it's lack of coffee, but I'm not clear on what you're asking for. – dnagirl Sep 14 '11 at 12:21
  • I thought so, but new Date(1316206740000) = Tue, 06 Dec 43678 07:20:00 GMT...So, it's a bad date and it must be more complex. What am I asking for? This snippet of javascript is on the deal page, that I'm trying to parse. And I wanna know the date, when the deal ends. – KafkaM Sep 14 '11 at 12:26

1 Answers1

0

javascript Date objects take milliseconds, not seconds, so

var d= new Date(1316206740000); 
document.write(d); //outputs Fri Sep 16 17:59:00 UTC-0300 2011
dnagirl
  • 20,196
  • 13
  • 80
  • 123
  • @KafkaM: well, if you are taking the millisecond value, you'll need to convert it to seconds. There are 1000 milliseconds in each second, so seconds=milliseconds/1000. – dnagirl Sep 14 '11 at 13:16