Back to vBulletin 4.x Add-ons

User-defined Date and Time display options
Mod Version: 1.00, by fwulfers

vB Version: 4.2.1 Rating: (4 votes - 5.00 average) Installs: 17
Released: 15 Oct 2013 Last Update: 15 Oct 2013 Downloads: 44
Not Supported Uses Plugins Additional Files Re-usable Code Translations  

This modification allows a user to select their own date and time format. vBulletin 4 only has the option to specify one format for one language or different formats for different languages. This allows the user to select the format regardless of the language.

Date Formats
International Format yyyy-mm-dd (example: 1998-04-25)
Expanded International Format (example: Mon 25 April 1998)
US Format mm/dd/yy (example: 04/25/98)
Expanded US Format (example: Mon Apr 25th, 1998)
European Format dd/mm/yy (example: 25/04/98)
Expanded European Format (example: Mon 25th Apr 1998)

Time Formats
24-Hour Time Format (example: 23:15)
12-Hour Time Format (example: 11:15 PM)

This 4.x modification is based on an old 3.x modification (User Defined Date & Time Format Display) and modified with a few new date options and tested on vB4. I didn't invent this mod and just used the original mod and user comments in that thread to make it easy for use on vBulletin 4.

This was tested on 4.2.1 but it should work for any 4.x version.

Installation:

Create 2 new user fields

AdminCP -> User Profile Fields -> Add New User Profile Field

Date field

Profile Field Type -> Single-Selection Menu
Title: Date Format
Description:
Format in which the date is presented on vBulletin pages.<br><br>International Format yyyy-mm-dd (example: 1998-04-25)<br>Expanded International Format (example: Mon 25 April 1998)<br>US Format mm/dd/yy (example: 04/25/98)<br>Expanded US Format (example: Mon Apr 25th, 1998)<br>European Format dd/mm/yy (example: 25/04/98)<br>Expanded European Format (example: Mon 25th Apr 1998)
Options
International Format
Expanded International Format
US Format
Expanded US Format
European Format
Expanded European Format
Set Default: Yes, but No First Blank Option
Which page displays this option: Options: Date / Time

Time field

Profile Field Type -> Single-Selection Menu
Title: Time Format
Description:
Format in which the time is presented on all vBulletin pages.<br><br>12-Hour Time Format (example: 11:15 PM)<br>24-Hour Time Format (example: 23:15)
Options
24-Hour Time Format
12-Hour Time Format
Set Default: Yes, but No First Blank Option
Which page displays this option: Options: Date / Time

Important: note the field names of the fields you just created. These can be different for your forum, depending on the other mods and plugins on your forum.

Any field option not mentioned above, use what you prefer.

Create new Plugin

You can either import the xml file or create the plugin manually.

Important: in the PHP code below or the imported xml plugin, you have to change the field names (switch ($vbulletin->userinfo['field#']) and replace field# with the names of the fields you created in the first step. For example: switch ($vbulletin->userinfo['field5']. To find the field names/numbers on your forum, go to AdminCP -> User Profile Field Manager and find the fields you created. The field names are in the Name column.

You can easily adjust the new fields and PHP code to remove or add any formats. The new Date and Time settings will show up under the General Settings for all users. Find more information about the possible date and time formats here: http://us1.php.net/manual/en/function.date.php

Import XML file

AdminCP -> Plugins & Products -> Download/Upload Plugins
Scroll down to the bottom, Choose the xml file and click Import

Create yourself

AdminCP -> Plugins & Products -> Add New Plugin

Product: vBulletin
Hook Location: global_start
Title: Custom Date and Time Formats
Execution Order: 5 (note: this is the default, seems to work fine)
Plugin PHP Code:

Code:
if ($vbulletin->userinfo['userid']) {
	// ############ Date Format as Uservalue ################
	switch ($vbulletin->userinfo['field55']) {
	case 'International Format':
		$vbulletin->options['dateformat'] = 'Y-m-d';
		break;
	case 'Expanded International Format':
		$vbulletin->options['dateformat'] = 'D d F Y';
		break;
	case 'US Format':
		$vbulletin->options['dateformat'] = 'm/d/y';
		break;
	case 'Expanded US Format':
		$vbulletin->options['dateformat'] = 'D M jS, Y';
		break;
	case 'European Format':
		$vbulletin->options['dateformat'] = 'd/m/y';
		break;
	case 'Expanded European Format':
		$vbulletin->options['dateformat'] = 'D jS M Y';
		break;
	case 'ISO Format':
		$vbulletin->options['dateformat'] = 'Y-m-d';
		break;
	case 'Counting Format':
		$vbulletin->options['dateformat'] = 'o:W:N/z';
		break;
	default:
		$vbulletin->options['dateformat'] = 'Y-m-d';
	}
	// ############ Time Format as Uservalue ################
	switch ($vbulletin->userinfo['field56']) {
	case '12-Hour Time Format':
		$vbulletin->options['timeformat'] = 'h:i A';
		break;
	case '24-Hour Time Format':
		$vbulletin->options['timeformat'] = 'H:i';
		break;
	case 'Swatch Internet Format':
		$vbulletin->options['timeformat'] = 'B';
		break;
	case 'Unix Epoch Format':
		$vbulletin->options['timeformat'] = 'U';
		break;
	default:
		$vbulletin->options['timeformat'] = 'H:i';
	}
}

Download

File Type: %1$s custom-date-and-time-vb-plugin.xml (1.6 KB, 46 downloads)

Screenshots

Click image for larger version
Name:	screen1.jpg
Views:	121
Size:	108.1 KB
ID:	146837   Click image for larger version
Name:	screen2.jpg
Views:	128
Size:	63.9 KB
ID:	146838   Click image for larger version
Name:	screen3.jpg
Views:	105
Size:	147.1 KB
ID:	146839   Click image for larger version
Name:	screen5.jpg
Views:	141
Size:	129.0 KB
ID:	146840  

Similar Mods

User Defined Date & Time Format Display vBulletin 3.5 Add-ons

vblts.ru supports vBulletin®, 2022-2024