Time convert problem

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

    Time convert problem

    Hi there,

    I get form a database time with the format : 'Jan 01 1900
    06:00PM'

    I want to convert it to :HH:MM
    I tryed it with $heure=(date("H :i",strtotime($ row[0]))
    but I get allways 20:55. even when time changes. Whats wrong ?

    Does anybody know where I can get a good function which will convert date to
    date and time to time with different formats ?

    Thanks in advance for any help

    Best regards

    Ralf



  • Alistair Baillie SS2002

    #2
    Re: Time convert problem

    its because its not a php timestamp.

    A quick search of google, revealed this;



    - Ali

    "Ralf Meuser" <rmeuser@free.f r> wrote in message
    news:426f7e2c$0 $25552$636a15ce @news.free.fr.. .[color=blue]
    > Hi there,
    >
    > I get form a database time with the format : 'Jan 01 1900
    > 06:00PM'
    >
    > I want to convert it to :HH:MM
    > I tryed it with $heure=(date("H :i",strtotime($ row[0]))
    > but I get allways 20:55. even when time changes. Whats wrong ?
    >
    > Does anybody know where I can get a good function which will convert date
    > to date and time to time with different formats ?
    >
    > Thanks in advance for any help
    >
    > Best regards
    >
    > Ralf
    >
    >
    >[/color]


    Comment

    • Colin McKinnon

      #3
      Re: Time convert problem

      Ralf Meuser wrote:
      [color=blue]
      > Hi there,
      >
      > I get form a database time with the format : 'Jan 01 1900
      > 06:00PM'
      >
      > I want to convert it to :HH:MM
      > I tryed it with $heure=(date("H :i",strtotime($ row[0]))
      > but I get allways 20:55. even when time changes. Whats wrong ?
      >
      > Does anybody know where I can get a good function which will convert date
      > to date and time to time with different formats ?
      >[/color]

      No, but wouldn't a simple substr(...) + check for AM/PM suffice?

      C.

      Comment

      • NC

        #4
        Re: Time convert problem

        Ralf Meuser wrote:[color=blue]
        >
        > I get form a database time with the format : 'Jan 01 1900 06:00PM'[/color]

        What type is the database field? DATETIME?
        [color=blue]
        > I want to convert it to :HH:MM
        > I tryed it with $heure=(date("H :i",strtotime($ row[0]))
        > but I get allways 20:55. even when time changes. Whats wrong ?[/color]

        Since strtotime() returns and unsigned Unix timestamp, it can only
        work with dates after the Unix epoch (January 1, 1970).
        [color=blue]
        > Does anybody know where I can get a good function which will convert
        > date to date and time to time with different formats ?[/color]

        You can format time on the database server:

        SELECT DATE_FORMAT(you r_time_field, '%H:%i') as formatted_time
        FROM your_table;

        Cheers,
        NC

        Comment

        Working...