Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8474081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:31:45+00:00 2026-06-10T17:31:45+00:00

Hi~ I am using PHPExcel 1.7.7 to read XLSX files and present the results

  • 0

Hi~ I am using PHPExcel 1.7.7 to read XLSX files and present the results in web pages.

I’m trying to get the value of a cell that stores a date & time string and process it in PHP using the following code.

<?php

date_default_timezone_set('Australia/Canberra'); 

$value = $objPHPExcel->getActiveSheet()->getCell('A1')->getValue();

define('MIN_DATES_DIFF', 25569);
define('SEC_IN_DAY', 86400);

function excel2Timestamp($excelDate)
{
  if($excelDate <= MIN_DATES_DIFF)  
  {
     return 0;
  }

  return ($excelDate - MIN_DATES_DIFF) * SEC_IN_DAY;
}

echo $result = date('H:i:s d/m/Y', excel2Timestamp($value)); 

?>

while the original value in the cell is “00:00:00 01/07/2012”, instead of giving me the correct results, the output from the above PHP code shows “10:00:00 01/07/2012”.

It seems that it is caused by the time zone differences, but I have already defined the time zone at the beginning of the code. No idea what is wrong with it.

Can anyone please help me with it? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:31:47+00:00Added an answer on June 10, 2026 at 5:31 pm

    Forget your function to convert to timestamp (I was doing the same too)… PHPExcel does the convertion automatically, so try doing this:

    //get the excel date value (if it's stored in the A1 cell)
    $excelDate = $objPHPExcel->getActiveSheet()->getCell('A1')->getValue();
    //converts from excel format to a datetime object
    $date = PHPExcel_Shared_Date::ExcelToPHPObject($excelDate);
    //format the date as you want.
    $formatedDate = $date->format('m/d/Y');
    

    It should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using phpexcel class to read .xls, .ods and .xlsx files, I need
How to set cell/column value dynamically using PHPExcel library? I am fetching result set
I am using PHPExcel library to read/write excel files. Now I want to generate
I am trying to read a number from an excelsheet using PHPExcel. The code
I'm using getCalculatedValue() in my PHPExcel to read 34 Excel files. Unfortunately there were
I have a PHP script that will generate a report using PHPExcel from data
I'm using the PHPExcel library to read an Excel file with many worksheets and
I am using phpexcel to write a xlsx file. It is working fine except
I am generating reports in .xlsx using PHPExcel. It was okay in the initial
I'm in the process of using PHPExcel. One of the requirements is that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.