Convert PHP time

1

I want to convert the time I get that comes from an input time (01:00) to the format "his" that I want the result to be 010000. I used this code, it worked but the error of notice.

$hour=date("his",$txthourstart);

How can I convert to this format?

    
asked by anonymous 26.11.2014 / 17:06

1 answer

1

Prefer to use the methods and classes provided by PHP to use the interpretation of temporal data. There are two main solutions:

Object Oriented (> = PHP 5.2)

$hourStart = DateTime::createFromFormat("H:i", $txthourstart);
$hour = $hourStart->format('His');

Procedural

$hour = date("His", strtotime($txthourstart));
    
26.11.2014 / 17:26