Combine date and time in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Combine date and time in php

    In my php application user should enter date and time separately. But i want to combine them to compare with database value. How can i do that?
    user input Date:2008-03-25
    User input time:11:30
    Eg;
    I want to combine tease two values to 2008-03-25 11:30
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    $user_input_dat e." ".$user_input_t ime

    Is that what you want?

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      Try combining them as suggested in the previous post and running them trough the strtotime function.
      Then you should have a timestamp which you can use to compare to your database values.

      Comment

      • ghjk
        Contributor
        • Jan 2008
        • 250

        #4
        Thanks for your reply. It is working.

        Comment

        • TheServant
          Recognized Expert Top Contributor
          • Feb 2008
          • 1168

          #5
          Originally posted by ghjk
          Thanks for your reply. It is working.
          Please could you post the working code so this post can help other users who might have the same problem.

          Comment

          Working...