0

I am getting data by using a json file and one of the variable is about time, like 19:00, as GMT+0. If i would like to convert this to GMT+2, i will need to add 2, but i couldnt figure out how... I am trying to do this in a Titanium project.

Tel4tel
  • 41
  • 2
  • 9

3 Answers3

1
var time = "19:00";
function incHour(t,hr){ return parseInt(hr) + 2; }
time = time.replace( /^(\d{1,2})/, incHour );
Joe Johnson
  • 1,823
  • 15
  • 19
1

i always recommend momentjs, if you think you are going to have to do more time manipulation

http://momentjs.com/

Aaron Saunders
  • 32,707
  • 5
  • 57
  • 77
0

Ref: How to add 30 minutes to a JavaScript Date object?

var d1 = new Date ('6/29/2011 4:52:48 PM'),
    d2 = new Date ( d1 );
d2.setHours ( d1.getHours() + 2 );
alert ( d2 );
Community
  • 1
  • 1
Chizl
  • 1,838
  • 15
  • 31