Date functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hayden Kirk

    #1

    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


  • Tom Thackrey

    #2
    Re: Date functions


    On 19-Mar-2004, "Hayden Kirk" <spam@spam.co m> 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

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • Hayden Kirk

      #3
      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.2635 7$sd2.10338@new ssvr29.news.pro digy.com...[color=blue]
      >
      > On 19-Mar-2004, "Hayden Kirk" <spam@spam.co m> 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@wil lglen.net (it's reserved for spammers)[/color]


      Comment

      • Tom Thackrey

        #4
        Re: Date functions



        On 19-Mar-2004, "Hayden Kirk" <spam@spam.co m> 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

        tom (at) creative (dash) light (dot) com
        do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

        Comment

        Working...