-1

Am currently running the following PHP version on my laptop

PHP Version 7.0.31-1+ubuntu16.04.1+deb.sury.org+1

Problem is when i run the below piece of code

echo date('b e, Y', strtotime('2013-02-01'));

i get the following output

b Africa/Nairobi, 2013

and yet it is supposed to produce the following output

Feb 1, 2013

What could be causing this?

kellymandem
  • 1,709
  • 3
  • 17
  • 27
  • 1
    `e` prints the timezone identifier and there is no `b` format character. If you want the abbreviated month and the day of month, use `M j, Y`. http://php.net/date – drew010 Sep 02 '18 at 15:54
  • Have a look at http://php.net/date - as you can see, the output is as expected. To get your desired output, you need the `M j, Y` format. – Qirel Sep 02 '18 at 15:55
  • See http://php.net/manual/en/function.date.php for documentation – Philip Thomson Sep 02 '18 at 15:56

3 Answers3

3

I think you might want to read the documentation for the date() function again. There is no b option that I'm aware of and:

e - Timezone identifier (added in PHP 5.1.0)

To achieve that result you'd want:

echo date('M j, Y', strtotime('2013-02-01'));

M - A short textual representation of a month, three letters

j - Day of the month without leading zeros

3

Try simply this M j, Y, See more formatting at official php documentation http://php.net/manual/en/function.date.php

 echo date('M j, Y', strtotime('2013-02-01'));

M A short textual representation of a month, three letters e.g Jan through Dec

j Day of the month without leading zeros e.g 1 to 31

Y A full numeric representation of a year, 4 digits e.g: 1999 or 2003

DEMO: https://3v4l.org/97Uvq

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103
1

PHP date B (not b) Swatch Internet time 000 through 999, e Timezone identifier (added in PHP 5.1.0)

You try code :

echo date('M j, Y', strtotime('2013-02-01'));

Out put:

Feb 1, 2013
Quan Lee
  • 146
  • 4