Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
User-defined Date and Time display options Details »»
User-defined Date and Time display options
Version: 1.00, by fwulfers fwulfers is offline
Developer Last Online: Jan 2019 Show Printable Version Email this Page

Category: End-User Options - Version: 4.2.1 Rating:
Released: 10-14-2013 Last Update: 10-14-2013 Installs: 17
Uses Plugins
Re-useable Code Additional Files Translations  
No support by the author.

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 (https://vborg.vbsupport.ru/showthread.php?t=97469) 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 Now

File Type: xml custom-date-and-time-vb-plugin.xml (1.6 KB, 44 views)

Screenshots

File Type: jpg screen1.jpg (108.1 KB, 0 views)
File Type: jpg screen2.jpg (63.9 KB, 0 views)
File Type: jpg screen3.jpg (147.1 KB, 0 views)
File Type: jpg screen5.jpg (129.0 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
2 благодарности(ей) от:
KGodel, NovoCiv

Comments
  #2  
Old 04-25-2014, 09:39 AM
AthenaOfDelphi AthenaOfDelphi is offline
 
Join Date: Mar 2014
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great little fix and nice clear instructions. Thanks

If any one else wants to allow users to use the board defaults if they haven't picked a format or to explicitly use them, then you can make the following change to the two case statements:-

PHP Code:
....
case 
'Forum Defaults':
    break;
default:
    
// Do nothing

I put the 'Forum Defaults' option at the top of the list of options in the two custom profile fields.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04671 seconds
  • Memory Usage 2,246KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_box_bit
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (2)post_thanks_postbit_info
  • (1)postbit
  • (5)postbit_attachment
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete