A191919
A191919

Reputation: 3452

Object with time in javascript

I have this

$.each(data, function (id, item) {
                    var tempDate = new Date();
                    var tempTime = item.Time;
                    debugger;
                    tempDate =new Date(parseInt(item.Date.replace("/Date(", "").replace(")/", ""), 10));
                    self.items.push({ Name: item.Name, Date: (tempDate.getMonth() + 1) + '/' + tempDate .getDate() + '/' + tempDate.getFullYear(), Time: tempTime });
                });

The main proble how to get time from tempTime it has type Object and function getHours do not work.

enter image description here

Upvotes: 1

Views: 51

Answers (1)

McMath
McMath

Reputation: 7188

If you just want to get the hours from tempTime, all you have to do is access the value of the Hours property, like so:

tempTime.Hours // => 11

Upvotes: 1

Related Questions