Getting CET offset

I have a server that logs players online at certain times for displaying on a webpage.

The problem is it says CET +1 always, even though that’s wrong. (The server is in the states)

What I do:

userFile.print(“Last updated: " + date + " (CET “);
int offs = cal.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000);
if (offs > 0)
{
userFile.print(”+”);
}
userFile.println(offs + “)
”);

It says CET +1 in my windows PC in denmark and CET +1 on my Linux server in the states.

What do I do wrong?

BTW. My calendar object is inited as:

Calendar cal = new GregorianCalendar();

According to the docs, it should give me the current time.

Thanks in advance

Ozak

I fixed the problem.

Call getTimeZone().getRawOffset on your calender object.
Then divide by 3600000 to get the hour as one hour is 60601000 milliseconds :slight_smile: