Categories > TinyButStrong general >

Problem with formating dates < 1970-01-01

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: achille
Date: 2003-12-07
Time: 13:00

Problem with formating dates < 1970-01-01

I'm trying to display a "1956-03-19" date coming from a MySQL database.
If I'm using [affaire.date_debut;frm=dd/mm/yyyy] in the template the result is 01/01/1970
If I'm using [affaire.date_debut] the result is "1956-03-19" : date ok, obviously not formated.

I'm afraid their is a problem with formating date. It might be linked with my config : MacOSX 10.3, php 4.3.3, tbs 1.81

ideas & solutions welcome
By: Skrol29
Date: 2003-12-07
Time: 18:55

Re: Problem with formating dates < 1970-01-01

Damned you're right !

That's a knowed bug of PHP : the function strtotime() doesn't support date before 1970 which is not specified in the manual.

The MySQL function UNIX_TIMESTAMP(), which is supposed to do the same, has the same bad bug.

I gonna think about a way to fix that problem. But I realise that recognizing and analysing the MySQL string returned for a date will probably not be enought because some other database system have a different output format.

:(

For the moment you should change your MySQL query in order to have the dates given in the format you need.
By: Skrol29
Date: 2003-12-08
Time: 11:43

Re: Problem with formating dates < 1970-01-01

Hi again,

I've made a small test with date values retrieved in PHP.
The PHP functions for MySQL and SQL-Server return both string values for a datetime typed valuein the database.
But the format is different.

Example 1: for the date 1959-12-20 18:15:30,
From MySQL, we have : '1959-12-20 18:15:30'
From SQLServer, we have : 'Dec 20 1959 06:16PM'

Example 2: for the date 1959-12-20 (without time part),
From MySQL, we have : '1959-12-20 00:00:00'
From SQLServer, we have : 'Dec 20 1959 12:00AM'

(bad time part for SQL-Server !)

So I guess it won't be easy to find a way to arrange the bug of the PHP function strtotime() for the dates before 1970 :(
By: achille
Date: 2003-12-08
Time: 11:53

Re: Problem with formating dates < 1970-01-01

I'm using the date type, and not the datetime type.
Maybe simpler....
By: Skrol29
Date: 2003-12-08
Time: 16:24

Re: Problem with formating dates < 1970-01-01

That's the same problem anyway.
A MySQL date type is like a datetime without time part.
It is retrieved into a string PHP variable all the same.