Question: I have this time: `02:00:00`, how would I format it `2:00pm`

I have tried:

```
var time = new Date(z.app_time),
h = time.getHours(), 
m = time.getMinutes();

```

but h returns NaN, same as m

Answer: 
One way:

```
var time = "02:00:00".split(":"),
    h = +time[0],
    p;

if (h > 12) {
    h -= 12;
    p = "pm";
} else {
    h = h || 12;
    p = "am";
}

var t = h + ":" + time[1] + p;

```
If you want to get current date so you don't need to give any parameter to `Date()` object.

Try this, it will give you the time as you want:

```
var time = new Date(),
h = time.getHours(), 
m = time.getMinutes();
ampm = h >= 12 ? 'pm' : 'am';
var finalTime = h + ':' + m + ampm;

```

Hope this helps.