Using localtime is fine if $newtime is a real time value. But from the description I assume it is a delta time. ie a value like 21870. Becasue of the zone offset, localtime would produce different results around the world. However gmtime() will always give what is wanted.