I am using few variables to store different php dates in desired formats like following:
$today = date('Y-m-d');
$todayPretty = date('d. M');
$oneMonthBefore = date('Y-m-d', strtotime('-1 months'));
$oneMonthBeforePretty = date('d. M', strtotime('-1 months'));
$oneMonthBefore2 = date('Y-m-d', strtotime($this->oneMonthBefore .' -1 day'));
$oneMonthBefore2Pretty = date('d. M', strtotime($this->oneMonthBefore .' -1 day'));
$twoMonthsBefore = date('Y-m-d', strtotime('-2 months'));
$twoMonthsBeforePretty = date('d. M', strtotime('-2 months'));
$currentMonth = date('F');
$previousMonth = date('F', strtotime('-1 months'));
Unfortunately I need them in a different language like danish for example so I've set up the following with no results:
setlocale(LC_ALL, "da_DK.UTF-8");
I've read that I have to use strftime
function but how I should approach this when it comes to the variables that doesn't use strtotime
in my case? Any help or guidance is more than welcomed.
At first you should check if you have installed your locale with:
in commandline.
if not you can do that on ubuntu/debian with:
In PHP you can also trying multiple deff's if your code will develop on windows and deploy on linux, like this: