preg_split to split offset time from time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmagesh
    New Member
    • Nov 2008
    • 119

    #1

    preg_split to split offset time from time

    Hi,

    I have a string which will get the time with offset time. Since it is offset. I may require to split either using - or +. below is my code I tried so far.

    Code:
    $idealedt = $_REQUEST['committime']; // $idealdt = 03:45-05:00
    $mytime = preg_split('/[-\+]/',$idealedt);
    This is not working at all. not sure where it goes wrong. Can any one help me on framing this please.

    Thanks in advance,
    Magesh
    Last edited by phpmagesh; Nov 26 '12, 07:29 AM. Reason: comment line identifier added
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Code works fine for me. Are you sure the string in $_REQUEST['committime'] is in the correct format?

    Comment

    • phpmagesh
      New Member
      • Nov 2008
      • 119

      #3
      Yes this is correct format. Simply the committime value will be like 05:35-05:00 or 05:35+05:00(HH: MM[-+]offset)

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Well, like I said earlier, the code works fine for me.

        Comment

        Working...