Changing between times

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

    Changing between times

    hey
    does anyone know to convert a time string in the form
    dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix time
    stamp or something that at least I can use to compare to a unix
    timestamp.

    Hope that makes sense

  • ZeldorBlat

    #2
    Re: Changing between times


    Iain Adams wrote:
    hey
    does anyone know to convert a time string in the form
    dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix time
    stamp or something that at least I can use to compare to a unix
    timestamp.
    >
    Hope that makes sense
    $string = '2006-08-01T15:45:11-00:00';
    $timestamp = strtotime($stri ng);

    Comment

    • Iain Adams

      #3
      Re: Changing between times

      Hey,

      When I try that I unfortunetely get -1. Any other ideas?

      ZeldorBlat wrote:
      Iain Adams wrote:
      hey
      does anyone know to convert a time string in the form
      dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix time
      stamp or something that at least I can use to compare to a unix
      timestamp.

      Hope that makes sense
      >
      $string = '2006-08-01T15:45:11-00:00';
      $timestamp = strtotime($stri ng);

      Comment

      • Rik

        #4
        Re: Changing between times

        Iain Adams wrote:
        ZeldorBlat wrote:
        >Iain Adams wrote:
        >>hey
        >>does anyone know to convert a time string in the form
        >>dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix
        >>time stamp or something that at least I can use to compare to a unix
        >>timestamp.
        >>>
        >>Hope that makes sense
        >>
        >$string = '2006-08-01T15:45:11-00:00';
        >$timestamp = strtotime($stri ng);
        When I try that I unfortunetely get -1. Any other ideas?
        Don't you mean the datatimestring should be '2006-08-01T15:45:11' instead of
        '2006-08-01T15:45:11-00:00'?

        If yes:
        list($date,$tim e) = explode('T',$st ring);
        list($year,$mon th,$day) = explode('-',$date);
        list($hour,$min ute,$second) = explode(':',$ti me);
        $time = mktime($hour,$m inute,$second,$ month,$day,$yea r);

        If not:
        list($date,$tim e) = explode('T',$st ring);
        list($year,$mon th,$day) = explode('-',$date);
        $time = substr($time,0, 8);
        list($hour,$min ute,$second) = explode(':',$ti me);
        $time = mktime($hour,$m inute,$second,$ month,$day,$yea r);

        Grtz,
        --
        Rik Wasmus


        Comment

        Working...