Forum:Local time in template

__NOWYSIWYG__

Our wiki has a template that has a parameter    where, if one sets it as     a timestamp will be included in a particular part of the template when it is rendered. Because the user’s signature will provide the timestamp in UTC, I thought it might be nice to have the timestamp rendered by the template in the user’s own time zone. Only, I cannot figure out how to do it. I’ve experiented with various time functions found at mw:Help:Magic words and m:Help:Magic word, but they seem to also use UTC. Perhaps a parser function for time might work, but I’m not sure. Any ideas? Thanks! — Spike Toronto  13:34, August 10, 2011 (UTC)


 * Well, I don't know how to stamp the local time for each user, but if you know the timezone you can set it with ( which produce  (UTC+2)) while  is the UTC time ( (UTC)). I used the parser functions for time. The problem is this way you have to set the timezone (maybe with a parameter). There are also the local time magic words but they gives the local time of the server. I don't have any other ideas right now. Maybe if there is a magic words to retrieve the time zone of the user' settings, you can use it for setting the time zone.


 * If timestamps are in different time zones, doesn't that defeat the point of a timestamp. Users would have to work out the offset if they see different people post with different zones --  Random Time  16:28, August 10, 2011 (UTC)


 * Some of us don't like converting the time if we don't happen to live in England. :-P -- Fandyllic (talk &middot; contr) 10 Aug 2011 4:19 PM Pacific


 * That may be true (I have to take an hour off, too) but if you're reading a thread, it's hard if other people are posting in other time zones to get a sense of what happened when, especially if the replies aren't in sequence. --  Random Time  23:24, August 10, 2011 (UTC)

 Leviathan : You’ve discovered what prompted me to post this query! The local time is actually the server’s local time, also stated in UTC.  RandomTime : With few exceptions, almost every user’s signature renders the time in UTC. What I wanted was for the timestamp in the template — which is additional to, not a replacement for, the timestamp in the signature — to render that timestamp in the viewer’s local time. That way, s/he would see the time stated for them both locally and in UTC. The idea was not to take anything way, but to add.""This would not be an issue if our Preferences permitted an option like the Change UTC-based times and dates, such as those used in signatures, to be relative to local time gadget at Wikipedia. You create a signature like normal, without any timecode. Then, when you type four tildes (i.e., ~ ), the system adds to your signature a timestamp. In other words, the normal, default way of doing things. The raw timestamp (i.e., how it appears in Source mode) is stated in UTC. But, wherever you look at the processed, rendered code (i.e., talkpages, user talkpages, page histories, noticeboards, recent changes, etc.), it appears translated into the viewer’s own time zone. Thus, for me, Leviathan’s timestamp, RandomTime’s timestamp, and my timestamp, would all appear — to me — in Eastern Daylight Time. Perhaps we should petition Wikia to add this gadget to wikis that request it. (To see what I mean, go to your Wikipedia preferences, if you have an account there, tick the appropriate box, save the new setting, then browse around the site and see how every timestamp is expressed in terms of your time zone.)""In the meantime, I would still like the template’s timestamp — as opposed to the signature’s — to render the time in the viewer’s local time. Thanks for the comments. Er … umm … any template coding ideas? Thanks! — Spike Toronto  01:50, August 11, 2011 (UTC)


 * Wouldn't you have to ensure users used said template? Otherwise the whole exercise would be mostly useless. -- Fandyllic (talk &middot; contr) 10 Aug 2011 7:08 PM Pacific


 * I don’t really understand the comment. Use the template, get the benefit of it. Don’t use the template, don’t get the benefit of it. To be honest, most of us who use the template rarely use the    parameter. But, for those of us who do (read, me!), it would be a nice added touch. Also, and to again be honest (yes! I split that infinitive!), I was intellectually fascinated by the possibility. — Spike Toronto  07:09, August 11, 2011 (UTC)


 * Wikipedia is able to have scripts like that because Wikipedia requires you to use default timestamping so that their bots can archive talk pages and properly sign unsigned posts. Since Wikia has no such restrictions, it would be nearly impossible to write a script capable of performing that task; both my sig and Fandyllics would not be recognized by the script at Wikipedia.


 * Thanks for that explanation Monch! I’ve kind of been wondering that. Anyway, at least in this exercise, it wouldn’t much matter that people at Wikia use these enormous sig codes to produce their sigs, because I just wanted to change how the template renders what the system produces when    is input within the template. The normal way of using it is:" "It was those five tildes inside that I wanted to work with, not the four tildes outside, which may or may not access enormous scripts kept on some subpage somewhere to generate a sig. But, if there is no magic word or a parser function for time that will translate the timestamp that had been produced by the five tildes to the viewer’s local time, then that’s the end of that. By the way, did I mention that once saved, the five tildes are replaced by an actual timestamp? So, I just want the system to take that time, apply the viewer’s time zone, and render that time on the screen locally. No go, though, eh? Thanks again for all your input guys! — Spike Toronto  07:09, August 11, 2011 (UTC)


 * I actually had to notify Wikpedia's bot to exempt my signature to stop it from auto-signing my posts. -- Fandyllic (talk &middot; contr) 10 Aug 2011 8:47 PM Pacific


 * But, over at WP you do not need the same sig code you have here, the one that renders the time in your time zone. You can go ahead and use the four tildes version with UTC, because everyone — including you — will see timestamps rendered onscreen in their time zone. In which case, you would not need to use SineBot’s opt-out option. — Spike Toronto  07:09, August 11, 2011 (UTC)


 * I saw the template in question, so you want the "target user" see the timestamp in its timezone, am I correct? The only solution I can think of is: in the template, if "timestamp=true or any other value" the template will add, now if there is a magic word that render the user's time zone, you can use it, otherwise a not-so-beautiful solution is that every user will create a subpage like   where they write their timezones (+1 in my case), so   will produce   that gives  . Maybe, it's more easier to put the timezone in the talk page of the user between &lt;includeonly>&lt;includeonly> like &lt;includeonly>+2&lt;includeonly> and then use  , but I don't know if it can conflicts with other things.
 * Note that the countries that are using the Daylight saving time, in summer you have to add an hour to you "timezone" variable, for example, now my "timezone" variable should be +2 not +1. Maybe you can set it with a formula like this one:


 * In my case (Italy), the daylight saving time begins the last Sunday of March at 02:00 am and ends at the last Sunday of October at 02:00 am. My time zone is UTC+1, but now we are in summer and in fact the formula gives:
 * I can help you setting for your country, or it can be even put in a template that changes accordingly with a given "begin" and "end" of the daylight saving time. Hope it can be helpful.
 * I can help you setting for your country, or it can be even put in a template that changes accordingly with a given "begin" and "end" of the daylight saving time. Hope it can be helpful.