-2

I am posting a time value from one page to another using html input type time. The posted value is displaying correctly but it doesn't show any output after applying strtotime().

Here is my HTML code

<form action="test.php" method="post">
    <input type="time" name="usr_time1">
    <input type="time" name="usr_time2">
    <input type="submit">
</form>  

and this is my php code

<?php
echo $t1= $_POST['usr_time1']."<br>";
echo $t2= $_POST['usr_time2']."<br>";
echo $timestamp = strtotime($t1);

What is wrong here..?

Rizier123
  • 58,877
  • 16
  • 101
  • 156
Abey
  • 1,408
  • 11
  • 26

3 Answers3

2

You are adding <br> to your time, just remove it or add it later.

<?php
$t1= $_POST['usr_time1'];
$t2= $_POST['usr_time2'];
echo $t1."<br>";
echo $t2."<br>";
echo $timestamp = strtotime($t1);
Sal00m
  • 2,938
  • 3
  • 22
  • 33
1

you are also adding <br> to $t1

roullie
  • 2,830
  • 16
  • 26
0

Remove the <br> appended

<?php
echo $t1= $_POST['usr_time1'];
echo $t2= $_POST['usr_time2'];
echo $timestamp = strtotime($t1);
aΨVaN
  • 1,104
  • 2
  • 9
  • 18