Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-10 15:25:12

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#3 2005-12-10 20:16:25

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#4 2005-12-16 02:05:07

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#6 2005-12-16 04:42:09

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

Board footer

Powered by FluxBB