Problem with the dates in the export of xls

QuestionsProblem with the dates in the export of xls
Eleni asked 7 years ago

Hello,

In the grid view of data i have 4 columns with date format.
In the columns i used the command:$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d/m/Y'); for the format of the dates but when i export the data some dates comes with the right format (m/d/Y) and others with the format d/m/Y and the weird is that the difference is in the same column e.g Start date

Could you please help me with this issue?

Kind regards,
Elenu

7 Answers
Abu Ghufran answered 7 years ago

Hi,

Please email me code + db sql test dump at [email protected]
I am unable to generate this case.

Eleni answered 7 years ago

For the start date i use the below code:

$col = array();
$col["title"] = "Start Date";
$col["name"] = "start_date";
$col["dbname"] = "start_date";
$col["width"] = "50";
$col["editable"] = false; // this column is not editable
$col["align"] = "center"; // this column is not editable
$col["search"] = true; // this column is not searchable
$col["formatter"] = "date";
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d/m/Y');
$col["align"] = "left";
$col["export"] = true;
$cols[] = $col;

The sql query is:

SELECT start_date,end_date,
FROM PMT_ACTIONS_2

Eleni answered 7 years ago

Hello,

one info about this issue when we deactivated the row:
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d/m/Y');

we took the format in the xls right but the column has not the appropriate format.
Do you think that there is something wrong with the function of "formatoptions"?

Abu Ghufran answered 7 years ago

I am unable to generate this issue and working fine with our demo (demos/integration/datepicker.php)
You can compare your code with it and re-check.

Alternate, you can email me complete code and database sample sql to generate test case here.

Eleni answered 7 years ago

Hi,

Finally we did the following change in the code:
from
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d/m/Y');
to
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d-m-Y');
and it works now

As for your information the issue has been noticed by many users and it with the format date.
Unfortunately,i cannot provide db data according the company's policy but you need to have a lot of rows to test the issue with the dates.

Thanks a lot for your help!

Abu Ghufran answered 7 years ago

Hi, Please email me code + database sql dump at [email protected]

avpman answered 7 years ago

I have the same problem but switching to the "-" instead of the "/" doesn't work for me. The date format function is really screwed up. It haphazardly formats some dates correctly and others incorrectly. I can provide code and database.

I have paid version.

Your Answer

17 + 7 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?