1

In relation with this question, I'm getting a wrong value for the the modified date when querying the windows ADODB connection for indexing files.

This is the line or the query:

$recordset - > Open("SELECT System.ItemName, System.DateModified FROM  SYSTEMINDEX  WHERE DIRECTORY='file:C:/xxxx/' AND CONTAINS('xxxx')", $conn);

I've getting good results on localhost (php 5.5.6), but not in other servers (php 5.5.8). I'm getting the wrong timestamp value and therefore it converts it into a wrong date when I use PHP functions to create my customized format:

date_default_timezone_set(ini_get('date.timezone'));

$date = $recordset->Fields->Item("System.DateModified")->Value;
$timestamp = variant_date_to_timestamp($date);  //getting a wrong date here

$file['date'] => date('d-M-Y H:i:s', $timestamp);

There's a different of some hours between the expected result and the result I'm getting. (2 hours)

It seems to be related with the variant_date_to_timestamp function of PHP. I've already set the proper date.timezone in the php.ini file and added the date_default_timezone_set call before calling variant_date_to_timestamp.

I'm using PHP 5.5.8.

I've found a similar problem/bug commented on 2004. It talks about the two hours difference as well. I find it difficult to believe it hasn't been solved yet.

Community
  • 1
  • 1
Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • Can you print the result of ini_get('date.timezone') from each server, and date_default_timezone_get() immediately before your date() command? I suspect the timezone is different between the servers. – Martin Apr 14 '14 at 12:59
  • I've set the correct timezone for each server. And yeah, it is different. But I still getting different results than the ones displayed for the windows explorer, which is also configured under the same timezone. – Alvaro Apr 14 '14 at 13:04
  • I get `Europe/Berlin` for both cases. – Alvaro Apr 14 '14 at 13:13
  • Does echoing the current timestamp also show a 2 hour offset? – Stijn van Grinsven Apr 18 '14 at 14:38
  • @StijnvanGrinsven yeah. It does. Even the PHP `date.timezone` is set correctly and the `ini_get('date.timezone')` return the correct value. Why is it? – Alvaro Apr 24 '14 at 09:13
  • The server date and time settings are also set properly. – Alvaro Apr 24 '14 at 09:24
  • It's been a few years, but I believe I dealt with something similar, if not the same, using ADODB. For some reason, the variant_date_to_timestamp function was returning incorrect timestamps. I ended up using variant_set_type($variant, VT_BSTR) to get a string representation of the date. This can be used for most variant types PHP doesn't handle. – Jeff Wooden Apr 24 '14 at 15:45

0 Answers0