Getting date (timestamp) as time value?

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

    Getting date (timestamp) as time value?

    Hi

    I'd like to read out a date from the a DB, but as time var. By default
    I seem to get it as a string.

    E.g.

    while(odbc_fetc h_row($result))
    {
    $tt= odbc_result($re sult,2);
    echo date("d.m.Y", $tt).", ".odbc_result($ result,6) . " <br>";

    S

  • Kimmo Laine

    #2
    Re: Getting date (timestamp) as time value?

    "Sonnich" <sonnich.jensen @elektrobit.com wrote in message
    news:1165307408 .725039.279250@ f1g2000cwa.goog legroups.com...
    Hi
    >
    I'd like to read out a date from the a DB, but as time var. By default
    I seem to get it as a string.
    >
    E.g.
    >
    while(odbc_fetc h_row($result))
    {
    $tt= odbc_result($re sult,2);
    echo date("d.m.Y", $tt).", ".odbc_result($ result,6) . " <br>";

    What kind of a string it is? If it's just a regular Y-m-d string, then the
    easiest would be first converting it to unix timestamp and then passing that
    to date:
    date("d.m.Y", strtotime($tt)) ;

    strtotime parses the formatted date string and converts it to integer.

    --
    "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
    http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
    spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


    Comment

    • Sonnich

      #3
      Re: Getting date (timestamp) as time value?


      Kimmo Laine wrote:
      "Sonnich" <sonnich.jensen @elektrobit.com wrote in message
      news:1165307408 .725039.279250@ f1g2000cwa.goog legroups.com...
      I'd like to read out a date from the a DB, but as time var. By default
      I seem to get it as a string.

      E.g.
      while(odbc_fetc h_row($result))
      {
      $tt= odbc_result($re sult,2);
      echo date("d.m.Y", $tt).", ".odbc_result($ result,6) . " <br>";
      >
      >
      What kind of a string it is? If it's just a regular Y-m-d string, then the
      easiest would be first converting it to unix timestamp and then passing that
      to date:
      date("d.m.Y", strtotime($tt)) ;
      >
      strtotime parses the formatted date string and converts it to integer.
      Server default format, I guess....
      2006-12-05 00:00:00

      Comment

      • Kimmo Laine

        #4
        Re: Getting date (timestamp) as time value?

        "Sonnich" <sonnich.jensen @elektrobit.com wrote in message
        news:1165309352 .222966.35270@1 6g2000cwy.googl egroups.com...
        >
        Kimmo Laine wrote:
        >"Sonnich" <sonnich.jensen @elektrobit.com wrote in message
        >news:116530740 8.725039.279250 @f1g2000cwa.goo glegroups.com.. .
        I'd like to read out a date from the a DB, but as time var. By default
        I seem to get it as a string.
        >
        E.g.
        while(odbc_fetc h_row($result))
        {
        $tt= odbc_result($re sult,2);
        echo date("d.m.Y", $tt).", ".odbc_result($ result,6) . " <br>";
        >>
        >>
        >What kind of a string it is? If it's just a regular Y-m-d string, then
        >the
        >easiest would be first converting it to unix timestamp and then passing
        >that
        >to date:
        >date("d.m.Y" , strtotime($tt)) ;
        >>
        >strtotime parses the formatted date string and converts it to integer.
        >
        Server default format, I guess....
        2006-12-05 00:00:00
        Then strtotime is your friend. Just pass the timestring the server gives to
        strtotime and use the timestamp it returns.


        --
        "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
        http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
        spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


        Comment

        • Sonnich

          #5
          Re: Getting date (timestamp) as time value?


          Kimmo Laine wrote:
          "Sonnich" <sonnich.jensen @elektrobit.com wrote in message
          news:1165309352 .222966.35270@1 6g2000cwy.googl egroups.com...

          Kimmo Laine wrote:
          "Sonnich" <sonnich.jensen @elektrobit.com wrote in message
          news:1165307408 .725039.279250@ f1g2000cwa.goog legroups.com...
          I'd like to read out a date from the a DB, but as time var. By default
          I seem to get it as a string.

          E.g.
          while(odbc_fetc h_row($result))
          {
          $tt= odbc_result($re sult,2);
          echo date("d.m.Y", $tt).", ".odbc_result($ result,6) . " <br>";
          >
          >
          What kind of a string it is? If it's just a regular Y-m-d string, then
          the
          easiest would be first converting it to unix timestamp and then passing
          that
          to date:
          date("d.m.Y", strtotime($tt)) ;
          >
          strtotime parses the formatted date string and converts it to integer.
          Server default format, I guess....
          2006-12-05 00:00:00
          >
          Then strtotime is your friend. Just pass the timestring the server gives to
          strtotime and use the timestamp it returns.
          jup, but I'd also like to check whether <null... I found a way though.

          Comment

          Working...