vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   User Defined Date & Time Format Display (https://vborg.vbsupport.ru/showthread.php?t=97469)

Dunhamzzz 05-25-2009 04:23 PM

I second the above post. Need a 3.8 version!

rsuplido 09-08-2009 07:21 PM

This will work on 3.8. Don't upload the XML. Just add the plugin directly using 'Add New Plugin' at the CP.

Product: vbuletin
Hook Location: global_start
Title: Custom Date & Time Formats
Execution Order: 5 - I don't know if this needs to be changed but 5 works fine on mine.
Plugin PHP Code:
PHP Code:

if ($vbulletin->userinfo['userid']) {
    
// ############ Date Format as Uservalue ################
    
switch ($vbulletin->userinfo['field7']) {
     case 
'US Format':
        
$vbulletin->options['dateformat'] = 'm-d-y';
        break;
     case 
'Expanded US Format':
        
$vbulletin->options['dateformat'] = 'M jS, Y';
        break;
     case 
'European Format':
        
$vbulletin->options['dateformat'] = 'd-m-y';
        break;
     case 
'Expanded European Format':
        
$vbulletin->options['dateformat'] = 'jS M Y';
        break;
     default:
        
$vbulletin->options['dateformat'] = 'm-d-y';
    }

    
// ############ Time Format as Uservalue ################
    
switch ($vbulletin->userinfo['field8']) {
     case 
'12-Hour Time Format':
        
$vbulletin->options['timeformat'] = 'h:i A';
        break;
     case 
'24-Hour Time Format':
        
$vbulletin->options['timeformat'] = 'H:i';
        break;
     default:
        
$vbulletin->options['timeformat'] = 'h:i A';
    }


Note that you still need to create the two user fields specified in the .txt file and change the 'fieldx' fields (I'm using field7 and field8 on mine) on the PHP Code (above) corresponding to the two field id's you have created.

Hope this helps.

MoMan 06-29-2010 05:43 PM

Quote:

Originally Posted by Bhuwan (Post 949150)
Very nice...I've installed this...The only complaint I had was it wasn't doing the bottom portion of the time (All times are in GMT <> The time now is <>).

The reason is becuase that is calcualted BEFORE global_start is executed, so it takes the lang default...I solved this by changing the code a bit and moving it to fetch_userinfo....

I've done this as well. Here is the code you need to use if you want to place the hook at fetch_userinfo:

PHP Code:

// ############ Date Format as Uservalue ################
    
switch ($user['field14']) {
     case 
'US Format':
        
$vbulletin->options['dateformat'] = 'm-d-y';
        break;
     case 
'Expanded US Format':
        
$vbulletin->options['dateformat'] = 'M jS, Y';
        break;
     case 
'European Format':
        
$vbulletin->options['dateformat'] = 'd-m-y';
        break;
     case 
'Expanded European Format':
        
$vbulletin->options['dateformat'] = 'jS M Y';
        break;
     default:
        
$vbulletin->options['dateformat'] = 'm-d-y';
    }

    
// ############ Time Format as Uservalue ################
    
switch ($user['field15']) {
     case 
'12-Hour Time Format':
        
$vbulletin->options['timeformat'] = 'h:i A';
        break;
     case 
'24-Hour Time Format':
        
$vbulletin->options['timeformat'] = 'H:i';
        break;
     default:
        
$vbulletin->options['timeformat'] = 'h:i A';
    } 

Remember to change 14 and 15 to whatever your fields are.

Amaury 07-16-2012 12:48 AM

Is it possible to add more formats or allow users to put in their own custom format via the modification's options in the Admin CP, such as here?

Edit: This would be used on a forum running vBulletin 4.2.0, as seen by my signature, but KH99 said it should work.

kh99 07-16-2012 01:32 AM

I guess I'll answer since the author hasn't been around in a while: You could add additional formats, since with this mod you have to manually create the custom profile fields anyway. You would need to add any additional formats to the custom profile field(s) and to the code in the plugin. (And in any case the plugin would probably need to be edited so that it's using the correct custom field numbers).

To allow a user to enter a custom setting you could create another profile field (or two, for date and time) that are text fields, then have each dropdown have an option for using the custom format. Then the plugin would have to check for the dropdown field being "Custom", and if so use the content of the text field as the format, like:

Code:

case 'Custom Date Format':
        $vbulletin->options['dateformat'] = $vbulletin->userinfo['fieldX'];
        break;


Snowhog 09-02-2012 09:22 PM

This is a very old MOD, and has never been modified since being posted. Never the less, in vBulletin Version 4.2.0 Patch Level 2 (currently), this 'feature' is lacking and many of our European members have lamented at this lack of what they feel, and I concur with, is an essential user setting.

I followed the instructions and had it setup within just a few minutes.

Marked as Installed, voted as Excellent, and nominated for MOTM.

Snowhog 09-08-2012 11:37 PM

Quote:

Originally Posted by kh99 (Post 2348525)
I guess I'll answer since the author hasn't been around in a while: You could add additional formats, since with this mod you have to manually create the custom profile fields anyway. You would need to add any additional formats to the custom profile field(s) and to the code in the plugin. (And in any case the plugin would probably need to be edited so that it's using the correct custom field numbers).

To allow a user to enter a custom setting you could create another profile field (or two, for date and time) that are text fields, then have each dropdown have an option for using the custom format. Then the plugin would have to check for the dropdown field being "Custom", and if so use the content of the text field as the format, like:

Code:

case 'Custom Date Format':
        $vbulletin->options['dateformat'] = $vbulletin->userinfo['fieldX'];
        break;


This is how we modified the MOD:
Code:

if ($vbulletin->userinfo['userid']) {
        // ############ Date Format as Uservalue ################
        switch ($vbulletin->userinfo['field5']) {
        case 'US Format':
                $vbulletin->options['dateformat'] = 'm-d-y';
                break;
        case 'Expanded US Format':
                $vbulletin->options['dateformat'] = 'M jS, Y';
                break;
        case 'European Format':
                $vbulletin->options['dateformat'] = 'd-m-y';
                break;
        case 'Expanded European Format':
                $vbulletin->options['dateformat'] = 'jS M Y';
                break;
        // ### Begin MOD by SteveRiley 2012-09-02 ###
        case 'ISO Format':
                $vbulletin->options['dateformat'] = 'Y-m-d';
                break;
        case 'Counting Format':
                $vbulletin->options['dateformat'] = 'o:W:N/z';
                break;
        // ### End MOD by SteveRiley 2012-09-02 ###
        default:
                $vbulletin->options['dateformat'] = 'm-d-y';
        }

        // ############ Time Format as Uservalue ################
        switch ($vbulletin->userinfo['field6']) {
        case '12-Hour Time Format':
                $vbulletin->options['timeformat'] = 'h:i A';
                break;
        case '24-Hour Time Format':
                $vbulletin->options['timeformat'] = 'H:i';
                break;
        // ### Begin MOD by SteveRiley 2012-09-02 ###
        case 'Swatch Internet Format':
                $vbulletin->options['timeformat'] = 'B';
                break;
        case 'Unix Epoch Format':
                $vbulletin->options['timeformat'] = 'U';
                break;
        // ### End MOD by SteveRiley 2012-09-02 ###
        default:
                $vbulletin->options['timeformat'] = 'h:i A';
        }
}


fpgeeks 05-06-2013 01:51 PM

Could someone please explain in simple, step by step instructions how to get this to work in 4.2.0?

fwulfers 10-15-2013 03:25 PM

I used the original mod instructions and the user comments in this thread to write up complete instructions for vB4: https://vborg.vbsupport.ru/showthread.php?t=303431

Thanks to all who contributed in this thread, hope you don't mind.


All times are GMT. The time now is 12:18 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01217 seconds
  • Memory Usage 1,775KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete