bartelsmedia Posted February 19, 2019 Posted February 19, 2019 I want to output the current local (server) time in 12h format. Would this code interfere with the Processwire core date/time if used in a hanna code? <? $ct = new DateTime("now", new DateTimeZone('Europe/Berlin')); echo $ct->format('h:i a'); ?> Does "new DateTimeZone" only affect this code or would it change the general timezone of the Processwire core, thus risking messing up database date/time stamps?
adrian Posted February 20, 2019 Posted February 20, 2019 You're all good - it won't affect the PHP / PW timezone. You can test stuff like this yourself - you can see that even though it's outputting the current time in Berlin in the first dump, the default timezone is still America/Los_Angeles 4
Autofahrn Posted February 20, 2019 Posted February 20, 2019 Tiny explanation: The new directive only creates a fresh instance of a PHP class in memory, in this case a DateTime and a DateTimeZone object. The latter is initialized to 'Europe/Berlin' and used as the timezone parameter for initializing the DateTime object, which, in turn, is stored in variable $ct. Nothing affects the system. 6
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now