How to make this format of date and time?

Hello, please tell me how to finish

$monthes = array(
 1 => ' January ', 2 => 'Feb', 3 => 'Mar', 4 => 'April',
 5 => 'may', 6 => 'June', 7 => 'July', 8 => 'August',
 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'
);
 $date = $row['date'];
 $adate = date("j", strtotime($date)) . $monthes[date("n", strtotime($date))] . date("Y", strtotime($date)) . date("H:i", strtotime($date));


Displays something like:
11 Jan 201515:52


And I have this:
January 11, 2015 15:52


How to put the padding (and put a space manually in the array of month) and the letter "g"?

Thanks in advance
September 19th 19 at 12:10
3 answers
September 19th 19 at 12:12
Solution
Make a better way:
$months = array(
 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar', 'Apr' => 'APR',
 'May' => 'may', 'Jun' => 'Jun', 'Jul' => 'Jul', 'Aug' => 'August',
 'Sep' => 'Sep', 'Oct' => 'Oct', 'Nov' => 'Nov', 'Dec' => 'December'
);
$date = str_replace(array_keys($months), array_values($months), date('j M HS., H:i', strtotime($row['date'])));
In so here. Give advice, use them, and not even put a mark "the decision"... =( - Cordie15 commented on September 19th 19 at 12:15
Super, thank you. - candid commented on September 19th 19 at 12:18
: put same) - candid commented on September 19th 19 at 12:21
September 19th 19 at 12:14
And this code is you who did?

In - found. 10 years ago I wrote :)

echo rdate().'<br>';
echo rdate(0,'d \p Y years').'<br>';
$date = '2015-01-11 15:52:00';
echo rdate($date,'d \p HS., H:i');


// \P (latinica) - Russian name of the month in the nominative case
// \p (latinica) - Russian name of the month in the genitive
function rdate($date = 0, $format = ")
{
 if (!$date) $date = time();

 if (!ctype_digit((string)$date))
{
 $date = strtotime($date);
}

 if (!$format) $format='d.m.y H:i';

 $rmon = array('January','February','March','April',
'may','June','July','August','September',
'October','November','December');
 $format = str_replace('\P',$rmon[date('n',$date)-1],$format);

 $rmon = array('Jan','Feb','Mar','APR',
'may','Jun','Jul','Aug','Sep',
'Oct','Nov','Dec');
$format=str_replace('\p',$rmon[date('n',$date)-1],$format);

 return date($format, $date);
}
I, Manu php date(). But a single line can not get result.

It is certainly possible to do so:
$adate = date("j", strtotime($date));
$amonthes = $monthes[date("n", strtotime($date))];
$ayear = date("Y", strtotime($date));
$atime = date("H:i", strtotime($date));

and withdraw: $adate $amonthes $of aweigh., $atime
but to do so is probably not correct. Here I think is better. - Cordie15 commented on September 19th 19 at 12:17
Well, what is not possible? need month you can withdraw, and a semicolon - no! who's stopping you to bring this unfortunate semicolon? - candid commented on September 19th 19 at 12:20
: led)
$tz = 'G.';
$adate $amonthes $ayear$tz $atime . It worked. - candid commented on September 19th 19 at 12:23
Did you do HELL. to stuff a string into a variable is NOT necessary. You can use it immediately. - candid commented on September 19th 19 at 12:26
and now look how it's actually written in one line. - Seth commented on September 19th 19 at 12:29
September 19th 19 at 12:16
$ php -a
Interactive mode enabled

php > setlocale(LC_TIME, 'ru_RU.UTF-8');
php > echo(strftime("%d %B %Yg., %H:%M", time()))."\n";
01 March 2015g., 14:09
php >

a good option, only a month, not leaning.

Find more questions by tags Work with date / timePHP