tags:

views:

15

answers:

2

I have a php script that runs on unix but I need it to run on windows.

setTimestamp is unix only and I need the windows equivalent.

http://php.net/manual/en/datetime.settimestamp.php

Example:

foreach($config['feeds'] as $feed){
    // in case we didn't save a last checked date, set it to sometime in the 70's
    $last_date = new DateTime();
    $last_date->setTimestamp(0);
    $last_date_save = 0;
    // the feeds are identified in the cache file by the hash of their url.
    $feed_hash = sha1($feed['url']);

    if(isset($stats[$feed_hash]['lastPubDate'])){
        if($config['debug'] > 0) echo "feed had lastpubdate\n";
        $last_date = new DateTime();
        $last_date->setTimestamp($stats[$feed_hash]['lastPubDate']);
    }

}

Any ideas?

A: 

setTimestamp is unix only

Tthis is a misunderstanding. The term "Unix timestamp" is used for the timestamp format that counts the number of seconds since January 1, 1970. It is just a name, not specific to Unix technically, and will work on Windows in the same way without problems.

Wikipedia: Unix Time

Pekka
+2  A: 

Myth:

settimestamp is NOT Unix-Only.

Real Reason:

The reason it is not working is because its availability is (PHP 5 >= 5.3.0) and your Windows machine may have an older version of PHP installed.

Solution:

  1. Insall latest PHP. OR:
  2. You can use the constructor of the class which is available (PHP 5 >= 5.2.0) like this:

    $last_date = new DateTime('@0'); // change construction line like this
    //$last_date->setTimestamp(0); // <-- remove this line

shamittomar
Thanks was using 5.2, swtiched to 5.3