Connecting Tech Pros Worldwide Help | Site Map

Date functions

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:18 AM
Hayden Kirk
Guest
 
Posts: n/a
Default Date functions

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



  #2  
Old July 17th, 2005, 04:18 AM
Tom Thackrey
Guest
 
Posts: n/a
Default 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)
  #3  
Old July 17th, 2005, 04:18 AM
Hayden Kirk
Guest
 
Posts: n/a
Default 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]


  #4  
Old July 17th, 2005, 04:19 AM
Tom Thackrey
Guest
 
Posts: n/a
Default 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)
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.