generate mysql timestamp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lars Plessmann

    #1

    generate mysql timestamp

    how can I generate a mysql timstamp value of the current time?

    sample:
    20040605042505
    YYYYMMDDhhmmss

    is it only possible by concat year.month.day. hours.minutes.s econds or is
    there any final function included in PHP to do that for me?
    I didn't find it, yet.


    I hope you can give me a hint?

    thanks,
    Lars
  • Tim Van Wassenhove

    #2
    Re: generate mysql timestamp

    In article <40c1224c$0$229 86$9b4e6d93@new sread2.arcor-online.net>, Lars Plessmann wrote:[color=blue]
    > how can I generate a mysql timstamp value of the current time?[/color]

    It's in the MySQL manual. Where it should be. Meaby you want to have a
    look at the NOW function overthere too.

    --
    Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>

    Comment

    • Lars Plessmann

      #3
      Re: generate mysql timestamp

      Tim Van Wassenhove wrote:[color=blue]
      > In article <40c1224c$0$229 86$9b4e6d93@new sread2.arcor-online.net>, Lars Plessmann wrote:
      >[color=green]
      >>how can I generate a mysql timstamp value of the current time?[/color]
      >
      >
      > It's in the MySQL manual. Where it should be. Meaby you want to have a
      > look at the NOW function overthere too.
      >[/color]

      No I need it in PHP to store it in an Object variable.
      So I don't want to call a SELECT or any other mysqwl based function.

      Comment

      • Tim Van Wassenhove

        #4
        Re: generate mysql timestamp

        In article <40c19040$0$229 96$9b4e6d93@new sread2.arcor-online.net>, Lars Plessmann wrote:[color=blue]
        > Tim Van Wassenhove wrote:[color=green]
        >> In article <40c1224c$0$229 86$9b4e6d93@new sread2.arcor-online.net>, Lars Plessmann wrote:
        >>[color=darkred]
        >>>how can I generate a mysql timstamp value of the current time?[/color]
        >>
        >>
        >> It's in the MySQL manual. Where it should be. Meaby you want to have a
        >> look at the NOW function overthere too.
        >>[/color]
        >
        > No I need it in PHP to store it in an Object variable.
        > So I don't want to call a SELECT or any other mysqwl based function.[/color]

        I'd use a unix timestamp then. Both PHP and MySQL know how to handle it.

        --
        Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>

        Comment

        • Philipp Kern

          #5
          Re: generate mysql timestamp

          On 2004-06-05, Lars Plessmann <Lars.Plessmann @gmx.de> wrote:[color=blue]
          > is it only possible by concat year.month.day. hours.minutes.s econds or is
          > there any final function included in PHP to do that for me?
          > I didn't find it, yet.[/color]

          The hint would be `date' and `format string'.
          date('YmdHis', $timestamp)

          But you could also save the timestamp as int(11) in the table.

          Bye,
          phil
          --
          Please send replies (not followups) to the address set in Reply-To.
          Philipp Kern - PK2186-RIPE - http://www.philkern.de

          Comment

          • Lars Plessmann

            #6
            Re: generate mysql timestamp

            Tim Van Wassenhove wrote:[color=blue]
            > In article <40c19040$0$229 96$9b4e6d93@new sread2.arcor-online.net>, Lars Plessmann wrote:
            >[color=green]
            >>Tim Van Wassenhove wrote:
            >>[color=darkred]
            >>>In article <40c1224c$0$229 86$9b4e6d93@new sread2.arcor-online.net>, Lars Plessmann wrote:
            >>>
            >>>
            >>>>how can I generate a mysql timstamp value of the current time?
            >>>
            >>>
            >>>It's in the MySQL manual. Where it should be. Meaby you want to have a
            >>>look at the NOW function overthere too.
            >>>[/color]
            >>
            >>No I need it in PHP to store it in an Object variable.
            >>So I don't want to call a SELECT or any other mysqwl based function.[/color]
            >
            >
            > I'd use a unix timestamp then. Both PHP and MySQL know how to handle it.
            >[/color]

            My question was if it is possible to generate a timestamp in the mysql
            format. I did not ask how to handle it better.
            There a several reasons why I have to do it in that way!

            Well, do you know a function? Otherwise I will generate it manually.


            thanks in advance,
            Lars

            Comment

            • Lars Plessmann

              #7
              Re: generate mysql timestamp

              Philipp Kern wrote:
              [color=blue]
              > On 2004-06-05, Lars Plessmann <Lars.Plessmann @gmx.de> wrote:
              >[color=green]
              >>is it only possible by concat year.month.day. hours.minutes.s econds or is
              >>there any final function included in PHP to do that for me?
              >>I didn't find it, yet.[/color]
              >
              >
              > The hint would be `date' and `format string'.
              > date('YmdHis', $timestamp)
              >
              > But you could also save the timestamp as int(11) in the table.
              >
              > Bye,
              > phil[/color]

              well, okay :)
              that was what I was searching for!

              thanks, Philipp!

              Comment

              Working...