Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Adjust from server time.
I’m using a bit of PHP to show current date and time on-screen. This is the time part:-
<code><?php echo date(“g:i A”); ?></code>
<br />
Of course it picks up the server time which is a different time-zone. Is there any way of making the time adjustment to bring it into my time zone?
Last edited by thebombsite (2005-12-10 15:26:27)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#2 2005-12-10 19:08:36
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Adjust from server time.
Yes. You can either use this, or do:
<txp:php>echo date('g:i A', time() + tz_offset());</txp:php>
Offline
Re: Adjust from server time.
Thank you Mary. PHP version for me. Teaches me more. :)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Adjust from server time.
Well I’m using the PHP code above and it works great for the time but the date isn’t changing at 00.00 GMT. Instead that doesn’t happen until 8.00am GMT as server time is PST. So short of using the plug-in is there a way of making the date adjust properly as well, and even if I used the plug-in, would that work any better? Does that “offset” work for the date?
EDIT
Yes it does. Is that the correct way of doing it?
Last edited by thebombsite (2005-12-16 02:09:01)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#5 2005-12-16 02:48:54
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Adjust from server time.
Try calling safe_strftime('%Y-%m-%d etc')
Alex
Offline
Re: Adjust from server time.
Thanks zem. I have the other code working now but I’ll look at that. Isn’t PHP fun? ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Pages: 1