-1

I have this date: 24/11/1987 and I would like to change its appeareance to look like this:

24 NOV

I have seen the date format and there is a variable which allows to show the date the way I need but how can I change an existing date?

This is the example found on the internet:

Textual month (and just the month) m "March", "jun", "DEC"

The m would be the variable needed in the function.

Thanks.

Victor York
  • 1,621
  • 4
  • 20
  • 55
  • http://php.net/manual/en/function.date.php -1 because this is a RTFM question – STT LCU Jan 08 '14 at 09:29
  • Both your question and RTFM can be answered through a quick google search. Please note that even if it may sound harsh, that acronym is a common internet word and should be read with a light, non aggressive tone. – STT LCU Jan 08 '14 at 09:32
  • Sorry but you should know, Im from Spain and many of these terms may not even exist here or if they do they may be called differently or I just never heard of it :P. – Victor York Jan 08 '14 at 09:35
  • I suspect that most developers worldwide have heard the RTFM acronym at one time or another.... if you haven't, the PHP Docs are available in [Spanish](http://www.php.net/manual/es/datetime.formats.date.php) though admittedly not in Catalan, and I believe Google also exists in Spain – Mark Baker Jan 08 '14 at 09:39
  • Sure thing, sorry about that, just thought that the purpose of this site is to help out (which you all do) but I see that the questions should be more specific and hard to find online I suppose. Will do next time! – Victor York Jan 08 '14 at 09:41
  • Sorry for the -1 but with PHP Date Questions I'm pretty picky: Those have all been answered before (if not you've got the chance to win a 500 Reputation Bonus Bounty - just claim in the PHP Chatroom (Room 11)). Therefore it's required you do intensive search before asking any new PHP Date question. – hakre Jan 08 '14 at 11:21

3 Answers3

2

strtotime thinks that by using slashes, it's an American format (MM/DD/YYYY) rather than European format (DD/MM/YYYY).

$date = '24/11/1987';
$date = str_replace('/', '-', $date);
echo date('d M', strtotime($date));

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

http://php.net/strtotime

Mave
  • 2,413
  • 3
  • 28
  • 54
2

Use this:

$date = str_replace('/', '-', "24/11/1987");
echo date("d M", strtotime($date))?>

You need to convert your date to 24-11-1987 since / will be considered as American `m/d/y. For more details see this. For date function see this

user2936213
  • 1,021
  • 1
  • 8
  • 19
0
$dateToConvert = new DateTime('24/11/1987');
echo $dateToConvert->format('d-M-Y');
cptnk
  • 2,430
  • 18
  • 29