Page 1 of 2

Boards date format

Posted: Fri Feb 04, 2011 8:01 am
by Jaymie1989
Hi,

I have a MOD installed that use's the boards date format that is set in the UCP and ACP. (This isnt a MOD question) This MOD shows the month and date on the topic pages. I am trying to shorten the time and date it shows.

Currently it shows like this
Local time: February 4th, 2011,
7:52 am
I want to have it all show on one line so I went into the UCP under Board preferences and changed 'My date format' to less than a minute ago / 04 Feb 2011, 07:57

My question is: How can I have the same date format on the whole board and for it to not be changed in the UCP.

Also my boards date format is 17 Jan 2011, 16:59 how can I add the am and pm after? I added the a after and there is no change.

Re: Boards date format

Posted: Fri Feb 04, 2011 1:35 pm
by tbackoff
Jaymie1989 wrote:My question is: How can I have the same date format on the whole board and for it to not be changed in the UCP.
You could try removing the option in the HTML file. In /styles/prosilver/template/ ucp_prefs_personal.html:

Code: Select all

	<dl>
		<dt><label for="dateformat">{L_BOARD_DATE_FORMAT}:</label><br /><span>{L_BOARD_DATE_FORMAT_EXPLAIN}</span></dt>
		<dd>
			<select name="dateoptions" id="dateoptions" onchange="if(this.value=='custom'){dE('custom_date',1);}else{dE('custom_date',-1);} if (this.value == 'custom') { document.getElementById('dateformat').value = default_dateformat; } else { document.getElementById('dateformat').value = this.value; }">
				{S_DATEFORMAT_OPTIONS}
			</select>
		</dd>
		<dd id="custom_date" style="display:none;"><input type="text" name="dateformat" id="dateformat" value="{DATE_FORMAT}" maxlength="30" class="inputbox narrow" style="margin-top: 3px;" /></dd>
	</dl>
Jaymie1989 wrote:I want to have it all show on one line so I went into the UCP under Board preferences and changed 'My date format' to less than a minute ago / 04 Feb 2011, 07:57
...
Also my boards date format is 17 Jan 2011, 16:59 how can I add the am and pm after? I added the a after and there is no change.
Have a read here. You could actually select "custom" and write your own date format. For exapmel, on my test board, I have mine set to this: Y-m-d, H:i:s and it outputs 2011-02-04, 08:34:57.

Re: Boards date format

Posted: Fri Feb 04, 2011 1:48 pm
by Jaymie1989
t_backoff wrote:
Jaymie1989 wrote:I want to have it all show on one line so I went into the UCP under Board preferences and changed 'My date format' to less than a minute ago / 04 Feb 2011, 07:57
...
Also my boards date format is 17 Jan 2011, 16:59 how can I add the am and pm after? I added the a after and there is no change.
Have a read here. You could actually select "custom" and write your own date format. For exapmel, on my test board, I have mine set to this: Y-m-d, H:i:s and it outputs 2011-02-04, 08:34:57.
Thanks for replying Tabitha.

I did try this custom one but it didnt work d M Y, H:i a I want to to show: 04 Feb 2011, 13:47 pm

Re: Boards date format

Posted: Fri Feb 04, 2011 1:53 pm
by tbackoff
I think am / pm is only available in the 12 hour format character(s). There's no need (in PHP's date format) to have am or pm, it's distinguished by the time in 24 hour format. 13:47 is 1:57 in the afternoon. Any particular reason you want to have am / pm added?

*EDIT* Looks like "a" is available. Let me test a few configurations.

Re: Boards date format

Posted: Fri Feb 04, 2011 1:59 pm
by tbackoff
When using a custom date format, d M Y, H:i a works fine for me.
ucp.png
ucp.png (1.02 KiB) Viewed 751 times
last_post.png
last_post.png (2.86 KiB) Viewed 751 times

Re: Boards date format

Posted: Fri Feb 04, 2011 2:09 pm
by Jaymie1989
With the date format in the UCP set as standard with a new install of phpBB3.

On topics my local time look like this
Local time: Fri Feb 04, 2011 1:59
pm
I want it to show as
Local time: 04 Feb 2011, 1:59 pm
Which should be:
j M Y, G:i a

but in my topic page it still shows as
Local time: Fri Feb 04, 2011 1:59
pm
Its only when I change the date format in the UCP that the time changes on the board. :? This is what is confusing as I don't want to time to be changed in the UCP so the date format is how I want it.

Do you understand or am I making it confusing? :lol:
1.png
1.png (2.8 KiB) Viewed 750 times
2.png
2.png (3.41 KiB) Viewed 750 times

Re: Boards date format

Posted: Fri Feb 04, 2011 2:13 pm
by tbackoff
Change the j to d and the G to H. Also, have you read this part?
t_backoff wrote:
Jaymie1989 wrote:My question is: How can I have the same date format on the whole board and for it to not be changed in the UCP.
You could try removing the option in the HTML file. In /styles/prosilver/template/ ucp_prefs_personal.html:

Code: Select all

	<dl>
		<dt><label for="dateformat">{L_BOARD_DATE_FORMAT}:</label><br /><span>{L_BOARD_DATE_FORMAT_EXPLAIN}</span></dt>
		<dd>
			<select name="dateoptions" id="dateoptions" onchange="if(this.value=='custom'){dE('custom_date',1);}else{dE('custom_date',-1);} if (this.value == 'custom') { document.getElementById('dateformat').value = default_dateformat; } else { document.getElementById('dateformat').value = this.value; }">
				{S_DATEFORMAT_OPTIONS}
			</select>
		</dd>
		<dd id="custom_date" style="display:none;"><input type="text" name="dateformat" id="dateformat" value="{DATE_FORMAT}" maxlength="30" class="inputbox narrow" style="margin-top: 3px;" /></dd>
	</dl>
You will still have to change it for each user (possibly a SQL query if you have alot of members). Removing that code removes it from UCP, so they shouldn't be able to change it.

Re: Boards date format

Posted: Fri Feb 04, 2011 2:23 pm
by Jaymie1989
d M Y, H:i a That is what I have but it still shows it as

Mon Jan 17, 2011 4:59 pm on the index page and on my topic pages.

I am the only member on this one.

Re: Boards date format

Posted: Fri Feb 04, 2011 2:26 pm
by tbackoff
Have you changed it in your UCP? The screenshot you posted is the ACP. Once you change it via your UCP, you can then remove the code I provided.

Re: Boards date format

Posted: Fri Feb 04, 2011 2:31 pm
by Jaymie1989
In the UCP I changed it back to Fri Feb 04, 2011 2:30 pm which is what it is by default in phpBB3 and then removed the HTML from the ucp_prefs_personal.html

If I change it to what I want in the UCP, It wont be the same for all the other users will it and I want it to be changed for all the other users.

Re: Boards date format

Posted: Fri Feb 04, 2011 2:35 pm
by tbackoff
The ACP date settings are for users who register (they are given those settings). Since you are already registered, you have to change it in your UCP and then remove the code.

Re: Boards date format

Posted: Fri Feb 04, 2011 2:36 pm
by Jaymie1989
Oh, I see.

Ill register another user and try it.

Re: Boards date format

Posted: Fri Feb 04, 2011 2:48 pm
by Pit$Bull
The same principle applies to the format.

The normal settings for phpBB are as follows:

ACP (admin control panel) Time should be set at UTC as this is what guests and users not logged in will see.
UCP (user control panel) Time should be set to each individual users preference.


Use this to check your Server Time

Re: Boards date format

Posted: Fri Feb 04, 2011 2:53 pm
by Jaymie1989
Erm,

In the ACP the date format is set as
D d M, H:i a which shows Fri 04 Feb, 14:46 pm

but on a new user it shows
04 Feb 2011, 14:46 pm

Any ideas?

The UCP field has been removed as well so the user could not have changed it.

Result:(Apache Version/PHP Version)
Server Apache/Nginx/Varnish
Scripting Language
Server Time Fri, 04 Feb 2011 14:53:05 GMT

Re: Boards date format

Posted: Fri Feb 11, 2011 12:12 pm
by stevemaury
The ACP setting has nothing to do with what a logged in user sees. By default, a users display is d M Y H:i, which is what you are seeing for the new user.

You could change the default for user_dateformat in the users table, which would affect all new users, and you can change the date format for existing usres. This query will do both:

Code: Select all

ALTER TABLE `phpbb_users` CHANGE `user_dateformat` `user_dateformat` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT 'D d M, H:i a';
UPDATE phpbb_users SET user_dateformat = 'D d M, H:i a';