Topic on Project:Support desk

Jump to: navigation, search

Program local timezone for extension

13
Reception123 (talkcontribs)

Hello, I would like to know how I could program the local time zone to show up for https://github.com/miraheze/CreateWiki/blob/master/SpecialRequestWiki.php instead of UTC. For example if my timezone is set as GMT -10 the Special:RequestWiki page should show the GMT - 10 time not the UTC.

Reception123 (talkcontribs)

@Ciencia Al Poder Any idea about this?

Ciencia Al Poder (talkcontribs)

No idea, although you should clarify who is 'my timezone'? server or client

Reception123 (talkcontribs)

Client's timezone

Ciencia Al Poder (talkcontribs)

The server has no idea about the client's timezone, that's not information that's sent in the request headers, so it will require JavaScript on the client to grab the timezone, and probably make an ajax call to the server to re-send the entire contents again in the correct timezone, or reparse all dates on the page with JavaScript (scary at best)

Reception123 (talkcontribs)

Hmm. Thanks for the response.

Reception123 (talkcontribs)

@Ciencia Al Poder Thinking about it, wouldn't it be possible if the clients timezone is set in Special:Preferences?

Ciencia Al Poder (talkcontribs)

Yes, you can use the same methods Special:RecentChanges and page histories use to format dates and times

Reception123 (talkcontribs)

@Ciencia Al Poder I'm not exactly sure how I would integrate that into an extension.

Ciencia Al Poder (talkcontribs)

You should probably hire a developer if you are not able to copy&paste what other parts of the code are already doing. I'm just a volunteer not actively working on MediaWiki code.

Reception123 (talkcontribs)

@Ciencia Al Poder Sorry for asking so much. If it's not to much bother could you at least point me to a similar extension that uses this type of code?

Ciencia Al Poder (talkcontribs)

It's done in MediaWiki core, you can see Special:Log, Special:RecentChanges, Special:Contributions and page histories. It shouldn't be hard to see how the dates are transformed to the user timezone set in preferences...

Reception123 (talkcontribs)

Thank you

Reply to "Program local timezone for extension"