Jump to content

Recommended Posts

Hi,

 

  Iam using PHP Excel Reader class to read the datas from the excel and inserting the values into Database accordingly.

 

The problem i face is when the date column field is read from the excel the value is not the same when inserted in the database in the server. Date decrements by one since in the reader.php in the class, the date column value has been converted to corresponding UNIX time stamp. Returned value differs from the original value in the excel. For e.g. the date column value in the excel is 6/17/2008 and it has been converted to UNIX timestamp and value inserted in the database is 06/16/2008.

 

Is there any solution for the above issue. Kindly reply back if there is any other information that is needed for the above issue.

 

How to read the date column from the excel as it is?

 

Any comments will be great help...

 

NOTE:Server PHP version is 5.2.6 and mysql version is 5.0.51

 

Thanks in advance,

Srinivasan

Link to comment
https://forums.phpfreaks.com/topic/132683-reg-php-excel-reader-date-colum/
Share on other sites

Well the simple solution would be to add 1 day to the value before inserting it.

 

Excel holds the data as a floating point value representing the number of days since 1st January 1900 or 1st January 1904. However, when the base date is 1st January 1900, it also believes that there was a 29the February of that year.

Without checking the code, I couldn't tell you why you're getting this discrepancy; but it may be related to the spurious 1900 leap day.

  • 3 weeks later...

Hi,

 

      I have tried that also by adding 1 day to the date read from the excel. whether this will be the right solution in all the cases. Since date column will be converted to unix timestamp from the date 1970.. In that case , server date will differ accordingly and the date will vary....

 

Please help on this...

 

Regards

Srini

Since date column will be converted to unix timestamp from the date 1970.. In that case , server date will differ accordingly and the date will vary....

 

Please help on this...

I can tell you how to convert an Excel timestamp to a php timestamp, and vice versa.

However, what I don't know is exactly what you're getting from your PHP Excel Reader class.

 

Give me an example of the data value that you're getting, and what you think it should be.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.