CodeIgniter Forums
How to set Date in dd.mm.yyyy format - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: How to set Date in dd.mm.yyyy format (/showthread.php?tid=81182)



How to set Date in dd.mm.yyyy format - Tajar_Dobro - 02-01-2022

Hi all, how can i set the date format in dd.mm.yyyy ?


RE: How to set Date in dd.mm.yyyy format - wdeda - 02-01-2022

I have two functions, below, that I use in a help file. They are in Portuguese but it is easy to change to other languages, they are self-explanatory.;

In Portuguese we use the preposition 'de' - in English, 'of' - between the day, month and year:
02 de fevereiro of 2022 => if it were also used in English it would look like this: 02 of February of 2022.

PHP Code:
function diames() // diames = daymonth
{
    setlocale(LC_TIME'pt''portuguese');
    date_default_timezone_set('America/Sao_Paulo');

    return utf8_encode(strftime('%d de %B'strtotime('today')));

}

function 
daymonth() // daymonthyear = daymonthyear
{
    setlocale(LC_TIME'pt''portuguese');
    date_default_timezone_set('America/Sao_Paulo');

    return utf8_encode(strftime('%d de %B de %Y'strtotime('today')));