0

This is my PHP code:

$timestamp2 = strtotime('13:30 04/12/2013');

But, I want to put the these variables in this code:

        $mi = mysql_real_escape_string($_POST['mi']);
        $ho = mysql_real_escape_string($_POST['ho']);
        $da = mysql_real_escape_string($_POST['da']);
        $mo = mysql_real_escape_string($_POST['mo']);
        $ye = mysql_real_escape_string($_POST['ye']);

So for example:

$timestamp2 = strtotime('$mi:$ho $mo/$da/$ye');

I tried already multiple possibilities with quotes and etc.. But it didn't have any succes. Can someone help me with this?

Thanks!

2
  • Is there a question here? If you're just trying to use strtotime on all the variables, put them in an array and run them through a foreach Commented Apr 29, 2013 at 16:58
  • Actually, my solution isn't what you are looking for. Didn't realize those were each dateparts and not dates by themselves. Commented Apr 29, 2013 at 17:05

1 Answer 1

5

mktime() does what you want, just be careful with the parameter order. Something like this should work:

$timestamp2 = mktime($ho, $mi, 0, $mo, $da, $ye);
Sign up to request clarification or add additional context in comments.

2 Comments

You're welcome. You can indicate that you accept the answer with the checkmark below the upvote/downvote arrows buttons.
I know, but I couldn't yet at that moment (had to wait 5 min.).. :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.