Question: I'm working with php and want to convert a time scrubbed from an xml file. The time in the XML is `<startTime>0945</startTime>` for 9:45 and `<startTime>1330</startTime>` for 1:30. 

I'm using `strtotime(xml_time)` to get the unix timestamp. But now I need to extract only the time itself. I don't need to compare it to the current time, I don't need to include any date information, and I'm not concerned with the timezone. Can anyone help me with which function to use (if different) or how to modify `strtotime()` to accomplish this?

Thanks!

Answer: 
To convert `1330` into `13:30` you can use any of the string manipulation functions, e.g.:

```
$input = '1330';
var_dump(mb_substr($input, 0, 2) . ':' . mb_substr($input, 2, 2));

```

[demo](https://3v4l.org/qLRit)

If you feed `strtotime()` with incomplete dates it'll fill the gaps with bits from current date and using the default time zone. This will lead to random unexpected results depending on what time it is when the script runs:

```
var_dump( date('H:i:s', strtotime('0230')) );

```

> 
> string(8) "02:30:00"
> 
> 
> 

```
var_dump( date('H:i:s', strtotime('0230', mktime(1, 30, 50, 3, 26, 2017))) );

```

> 
> string(8) "03:30:00"
> 
> 
>
You can use [date](http://php.net/manual/en/function.date.php) to extract the time parameters you need:

```
echo $time = date("H:i:s",strtotime($xml_time));

```