Welcome Guest, Not a member yet? Register   Sign In
global date format
#1

[eluser]peter222[/eluser]
I there any way to set global date format (dd-mm-YYYY) that comes from MySQL database? It is not comfortable to use php date() function in all application places. I want to user can set it in preferences how data is displayed in all aplication. How to do it?
#2

[eluser]pistolPete[/eluser]
If you want to use a user specific date format, store the format string in the session's userdata.
Retrieve the string wherever you need to display a date and pass it to PHP's date() function or one of the Date Helper functions.
#3

[eluser]peter222[/eluser]
Thank You for help. Finally I have done it this way:

set constans:
Code:
define('DATEFORMAT','d-m-YYYY');

and wrote dth_helper:

Code:
if ( ! function_exists('dth'))
{
    function dth($date)
    {

        return date(DATEFORMAT,strtotime($date));
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB