Click here to Skip to main content
15,891,248 members

Comments by amarasat (Top 124 by date)

amarasat 25-Jun-14 17:22pm View    
Can you give me an example on how to do it? Is this correct, am i getting the offset between the current server and the GMT?

$ServerTimeZone = date_default_timezone_get();
$ServerDateTimeZone = new DateTimeZone($ServerTimeZone);
$Offset = new DateTime('now', $ServerDateTimeZone);

echo $Offset->getOffset();
amarasat 24-Jun-14 17:51pm View    
I have a server which returns 2 hours of data. A webpage reads this data and displays on a trend. Now when i read the data and display it, the data is off by three hours because client is in EST and server is in PST. If i can get the time difference between server and client i can shift my data on the trend by that many hours.

One way is
On Client, Date.getTimezoneOffset() is giving the offset from UTC and GMT. Is there any function in php that gives same type of offset on the server side? If i echo that, i can get the difference in times.
amarasat 15-Nov-13 10:57am View    
Sorry SA, i think i updated the link after a while. Its

http://jsfiddle.net/GV4Ww/9/. Are you sure this is the link that did not work?
amarasat 15-Nov-13 10:31am View    
you said "Everything works". Ok may be i misunderstood strings. To explain this better i have constructed this jsfiddle.

http://jsfiddle.net/GV4Ww/8/

Can you make that work? When user types a time or date in the form i have shown in the input boxes in the same format and click apply, can you alert the date?

See how Show2 sjhows the date but Show shows and invalid date
amarasat 15-Nov-13 9:03am View    
No this didn't work either.

EndDateAndTime = "2013,11,14,03,00,00";
EndDateAndTime = EndDateAndTime.replace(/"/g, '');
var CurrentTime = (new Date(EndDateAndTime));
CurrentTime value is Date {Invalid Date}