-1

I want to convert two integer as a time like:

$hour = 13;
$minute = 45; 

---> $result = 13:45:00 //(In TimeFormart)

after I combine that i have to do some SQL Querys and PHP Calculations

can somebody help me?

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
  • 3
    Please allow us to help you by showing your examples so far of the code you have produced whilst trying to find a solution. – Hoppo Jun 06 '20 at 11:16
  • Does this answer your question? [How to combine two strings together in PHP?](https://stackoverflow.com/questions/8336858/how-to-combine-two-strings-together-in-php) – joakimriedel Jun 06 '20 at 19:59

4 Answers4

0

Even when your question is very difficult to understand. Nobody knows what exactly you want to do and in which way and volume.

The only correct way to do it is this way:

$hour = 13;
$minute = 45; 
$seconds = 0;

$result = date('H:i:s', mktime($hour, $minute, $seconds));

echo $result;
// output: 13:45:00

Important: When using it for making a time, you must pass hour, minute, seconds - if you dont pass seconds it takes the current time seconds.

You can even pass day, month, year for more information check out the PHP Reference. https://www.php.net/manual/de/function.mktime.php

ChrisG
  • 202
  • 2
  • 13
-1

Try this code may be it help you.

<?php
      $hour = 13;
      $minute = 45; 
      $second=35;

      // $result = 13:45:00 //(In TimeFormart)
      $result = $hour.":".$minute.":".$second;
      echo $result; 
?>
-1

here's what you want, but if you put more than 24 in hour, it'll accept, it just returns you how many hours, minutes and seconds not that actual time

$hour = 13;
$minute = 45;
echo date($hour.':'.$minute.':s');
Rohit Sahu
  • 284
  • 5
  • 15
-1
$hour = 13;
$minute = 45; 
$result = $hour . ':' . $minute . ':' . '00';
echo $result;

output---> 13:45:00 //(In TimeFormart)