Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

date more specific

hello back again with another question,
In the discussion i can see that the date is shown only by the day and the month. Is there a way to make it more specific?
Per example: now in a discussion i have in the meta: Started by: admin, 2 January, Most recent by : xxx
I would prefer: Started by ; admin, 31-12-2013 2.50 PM, Most recent by: xxx

Tagged:
«1

Comments

  • The following can be set in config.

    $Configuration['Date']['DefaultTimeFormat'] = '%l:%M%p'; // If in current day
    $Configuration['Date']['DefaultDayFormat'] = '%B %e'; // If in same year
    $Configuration['Date']['DefaultYearFormat'] = '%B %Y'; // If not in same year
    $Configuration['Date']['DefaultFormat'] = '%B %e, %Y'; // general applications
    $Configuration['Date']['DefaultDateTimeFormat'] = '%c'; // date/time used in attributes
    

    Follow this guide for formatting options

    http://uk3.php.net/strftime

    do not confuse the formatting with this spec

    http://uk3.php.net/manual/en/function.date.php

    there are different and will not produce the same results.

    grep is your friend.

  • so if you don't want the informality you can make the more recent the same format.

    grep is your friend.

  • well, i do not succeed in this. I put the code above in config.php but nothing changes. I really need some help with this...

  • x00x00 MVP
    edited January 2014

    @jackmaessen said:
    well, i do not succeed in this. I put the code above in config.php but nothing changes. I really need some help with this...

    Doh! It is supposed to be Locale not config sorry

    Create a file called locale.php in /conf and put this

    <?php if (!defined('APPLICATION')) exit();
    $Definition['Date.DefaultTimeFormat'] = '%l:%M%p'; // If in current day
    $Definition['Date.DefaultDayFormat'] = '%B %e'; // If in same year
    $Definition['Date.DefaultYearFormat'] = '%B %Y'; // If not in same year
    $Definition['Date.DefaultFormat'] = '%B %e, %Y'; // general applications
    $Definition['Date.DefaultDateTimeFormat'] = '%c'; // date/time used in attributes
    

    Note those values are the defaults you still have to read the link as to how to fomat how you want.

    grep is your friend.

  • jackmaessenjackmaessen ✭✭✭
    edited January 2014

    Well, i changed my locale.php in the conf folder and it now looks like this:

    <?php
    ob_start("ob_gzhandler");
    if (!defined('APPLICATION')) exit();
    $Definition['Date']['DefaultTimeFormat'] = '%l:%M%p'; // If in current day
    $Definition['Date']['DefaultDayFormat'] = '%B %e'; // If in same year
    $Definition['Date']['DefaultYearFormat'] = '%B %Y'; // If not in same year
    $Definition['Date']['DefaultFormat'] = '%B %e, %Y'; // general applications
    $Definition['Date']['DefaultDateTimeFormat'] = '%A %c'; // date/time used in attributes
    

    But still nothing has changed. Below a snapshot what i prefer:

    and

  • you need to change the right hand side of the equation in the definitions to reflect the date formats you want.

    and you must delete the ini files in cache folder when changing or adding locale files.

    http://www.php.net/manual/en/function.date.php

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • x00x00 MVP
    edited January 2014

    @peregrine said:
    you need to change the right hand side of the equation in the definitions to reflect the date formats you want.

    and you must delete the ini files in cache folder when changing or adding locale files.

    http://www.php.net/manual/en/function.date.php

    That is the wrong format use

    http://uk3.php.net/strftime

    grep is your friend.

  • @jackmaessen please read through my post again.

    grep is your friend.

  • x00x00 MVP
    edited January 2014

    why on earth are you putting ob_start("ob_gzhandler"); ? For one it is not a file that you ever want anyone to access directly or output to the buffer.

    btw output compression is usually done on the server level these days, and it is smart based on the capability of the browser.

    grep is your friend.

  • sorry x00

    regarding formats.

    follow x00's instructions. regarding formats.

    but deleting ini files from cache folder - may help when adding locale files.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • jackmaessenjackmaessen ✭✭✭
    edited January 2014

    Well....it still doenst work for me.
    This is what is in my locale.php:

    if (!defined('APPLICATION')) exit();
    $Definition['Date']['DefaultTimeFormat'] = '%A %l:%M%p'; // If in current day
    $Definition['Date']['DefaultDayFormat'] = '%A %B %e'; // If in same year
    $Definition['Date']['DefaultYearFormat'] = '%A %B %Y'; // If not in same year
    $Definition['Date']['DefaultFormat'] = '%A %B %e, %Y'; // general applications
    $Definition['Date']['DefaultDateTimeFormat'] = '%A %c'; // date/time used in attributes
    

    As you can see the %A must at least show some day of the week in one of them. But nothing changed.
    I deleted all the .ini files in the cache folder and i emptied my browsers cache but still no result.
    what i am doing wrong?

    About the gzhandler: the main problem is that my hostprtovider does not support gzip. But i noticed with info.php file that gzip is enabled. So i put this line in the php files and i made a .htaccess to force Apache to gzip

  • peregrineperegrine MVP
    edited January 2014

    thanks for letting us try to help you that is awesome and insightful of you. @jackmaessen

    put this in as a test to check if "Discussions" changes to "Posts" to see if you are actually reading the locale.php.

    if (!defined('APPLICATION')) exit();     
    

    $Definition['Discussions'] = 'Posts'; to see if it changes to posts.
    $Definition['Date']['DefaultTimeFormat'] = '%A %l:%M%p'; // If in current day
    $Definition['Date']['DefaultDayFormat'] = '%A %B %e'; // If in same year
    $Definition['Date']['DefaultYearFormat'] = '%A %B %Y'; // If not in same year
    $Definition['Date']['DefaultFormat'] = '%A %B %e, %Y'; // general applications
    $Definition['Date']['DefaultDateTimeFormat'] = '%A %c'; // date/time used in attributes

    never got a chance to read these huh!

    http://vanillaforums.org/discussion/23130/forum-post-ettikett-etiquette

    http://vanillaforums.org/discussion/17954/food-for-thought-forum-etiquette

    http://vanillaforums.org/discussion/23483/advice-for-all-those-just-starting-out-with-vanilla

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • no nothing changes; so locale.php is not being read?

  • people aren't reading my post.... look carefully at it then compare it to yours.

    grep is your friend.

  • x00x00 MVP
    edited January 2014

    About the gzhandler: the main problem is that my hostprtovider does not support gzip. But i noticed with info.php file that gzip is enabled. So i put this line in the php files and i made a .htaccess to force Apache to gzip

    this is what is known as cargo cult programming.
    http://en.wikipedia.org/wiki/Cargo_cult_programming

    grep is your friend.

  • x00x00 MVP
    edited January 2014

    one you are confusing two solutions. Either you are using the apache module, or you are doing in it in php.

    In order to use an output buffer function you should first understand the output buffer is.

    Lastly this framework is MVC which mean these files aren't requested directly (and the configuration/locale files rarely are). Everything goes through a single dispatcher, so putting this on the top of all php files is pointless. You risk out output errors, such as whitespace errors.

    grep is your friend.

  • jackmaessenjackmaessen ✭✭✭
    edited January 2014

    Well, i finally found the solution.
    Why did it not working? The [Date] should be removed from the code in locale.php and embed in the second
    This works:

    if (!defined('APPLICATION')) exit();
    $Definition['Date.DefaultFormat'] = '%A %e %B, %Y';
    $Definition['Date.DefaultDayFormat'] = '%A %e %B %H:%M';
    $Definition['Date.DefaultYearFormat'] = '%A %e %B %Y';
    $Definition['Date.DefaultTimeFormat'] = '%A %l:%M%p';
    $Definition['Date.DefaultDateTimeFormat'] = '%A %e %B, %Y %l:%M%p %H:%M';
    

    That was the main reason why it did not work for me.
    I also added more specific date in the discussions. In helper_functions.php i added these lines to it:

    <span class="DateCreated">
                <?php
    
            setlocale(LC_ALL, 'nl_NL');
               $indate = $Sender->EventArguments['Comment']->DateInserted;
     $subindate = substr($indate, 0, 10);
     $subyear = substr($indate, 0, 4);
     $toyear = date('Y');
     $todate = date('Y-m-d');
    
     if ($todate == $subindate) {
     echo Anchor(Gdn_Format::Date($Object->DateInserted), $Permalink, 'Permalink', array('name' => 'Item_'.($CurrentOffset+1), 'rel' => 'nofollow'));
     } else {
     if ($subyear == $toyear) {
     echo Anchor(Gdn_Format::Date($Object->DateInserted, ('%A %d %B %R')), $Permalink, 'Permalink', array('name' => 'Item_'.($CurrentOffset+1), 'rel' => 'nofollow'));
     } else {
     echo Anchor(Gdn_Format::Date($Object->DateInserted, ('%d %B %Y')), $Permalink, 'Permalink', array('name' => 'Item_'.($CurrentOffset+1), 'rel' => 'nofollow'));
     }
    
     } ?>
             </span>
    

    Actually, my opinion, these settings must be part of the core files with a easy user interface so that anyone can modify it to its own wishes. For people who are not familiar with php code, this is hardly impossible. It should be easy to adjust to everyone.

  • x00x00 MVP
    edited January 2014

    Actually, my opinion, these settings must be part of the core files with a easy user interface so that anyone can modify it to its own wishes. For people who are not familiar with php code, this is hardly impossible. It should be easy to adjust to everyone.

    ??? It is the core, and configurable, what more do you want? If you wish to edit helper_functions.php (which don't really need to in this case), you should copy the view over to your theme and place it is n the views/discussions/

    Vanilla is called vanilla for a reason. it is not called tutti-fruti, therefore any interface would be more applicable as a plugin I would have thought.

    grep is your friend.

  • you code is also somewhat redundant because you can achieve what you through the correct settings of those definitions, you are re-inventing the wheel.

    you are placing code in hacky way, without notion of architecture.

    grep is your friend.

  • jackmaessenjackmaessen ✭✭✭
    edited January 2014

    yes you are right x00: this is the core, but i actually mean: there should be a nice userinterface for people who are not familiar with code so that they can easily change the date formats to their own wishes.
    Something like:

    in which country do you live ? per example : holland) -> all the english date and timenames become dutch
    What do you want to be displayed: - day of week
                                                          - name of day of the week 
                                                          - month
                                                          - name of month 
                                                          - year
                                                           -time -> - 14:00
                                                                          -  2:00 PM
                                                          - seconds -> people can choose by clicking checkboxes
    where do you want the date is displayed: 1 In All Discussions
                                                                    2 In the discussion 
                                                                    3 in the sidebar -> people can choose by clicking checkboxes
                                                                    4 more options...
    Where should the date be displayed: right upper corner
                                                             left upper corner
                                                             left bottom corner
                                                             right bottom corner
                                                             right beside the username ->people can choose by clicking checkboxes
                                                             more choices...
    

    Something like this in a nice userinterface that people only have to choose the checkboxes and the code is parsed in sort of a config file

Sign In or Register to comment.