Connecting Tech Pros Worldwide Help | Site Map

Date functions

Hayden Kirk
Guest
 
Posts: n/a
#1: Jul 17 '05
Ok

This is really anoying me...

I am using a timestamp colum in my MySQL table, I generate a timestamp with
php using time(); When I pull the time from the table I get some date from
the 1970's... does anyone know whats going on? Im using the date() function
to display the timestamp.

Thanks


Tom Thackrey
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Date functions



On 19-Mar-2004, "Hayden Kirk" <spam@spam.com> wrote:
[color=blue]
> I am using a timestamp colum in my MySQL table, I generate a timestamp
> with
> php using time(); When I pull the time from the table I get some date from
> the 1970's... does anyone know whats going on? Im using the date()
> function
> to display the timestamp.[/color]

Without seeing your code I would guess that you are inserting the time()
directly into the timestamp column. This won't work because mysql is not
expecting a unix timestamp. Change the column type to int or insert a proper
mysql time.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Hayden Kirk
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Date functions


Ah ok

That is the problem

What is the mysql time format? I thought it was a unix time stamp?

Could I get a breif example please...

I know this is a linux n00b question... but why do dates start at 1970?

Thanks

"Tom Thackrey" <use.signature@nospam.com> wrote in message
news:J8L6c.26357$sd2.10338@newssvr29.news.prodigy. com...[color=blue]
>
> On 19-Mar-2004, "Hayden Kirk" <spam@spam.com> wrote:
>[color=green]
> > I am using a timestamp colum in my MySQL table, I generate a timestamp
> > with
> > php using time(); When I pull the time from the table I get some date[/color][/color]
from[color=blue][color=green]
> > the 1970's... does anyone know whats going on? Im using the date()
> > function
> > to display the timestamp.[/color]
>
> Without seeing your code I would guess that you are inserting the time()
> directly into the timestamp column. This won't work because mysql is not
> expecting a unix timestamp. Change the column type to int or insert a[/color]
proper[color=blue]
> mysql time.
>
> --
> Tom Thackrey
> www.creative-light.com
> tom (at) creative (dash) light (dot) com
> do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)[/color]


Tom Thackrey
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Date functions




On 19-Mar-2004, "Hayden Kirk" <spam@spam.com> wrote:
[color=blue]
> What is the mysql time format? I thought it was a unix time stamp?
>[/color]

The manual is your friend:
http://www.mysql.com/doc/en/Date_and_time_types.html

[color=blue]
> Could I get a breif example please...[/color]

'2004-03-19 12:00:00'
[color=blue]
>
> I know this is a linux n00b question... but why do dates start at 1970?[/color]

The Unix timestamp was the system time on the original Unix systems. There
was no need for dates prior to 1970, so it was defined as the number of
seconds since Jan 1, 1970.



--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Closed Thread