How to leave the date in this format 27-Feb-17 at 21:52

Asked

Viewed 36 times

2

quick thing I need to know how I leave the date in this format 27-Feb-17 at 21:52 my code is this <?php echo date('d/m/Y H:i', $news['published']); ?>

1 answer

3


To documentation has exactly what you want, which is the M (for the month to be in the format of Jan until Dec) and the y (for the year to be in the format of two numbers, where 2017 is 17).

So just change to the format to:

echo date('d-M-y \a\s H:i', $news['published']);

Test it out here.


  • The d is the day with 0 to the left (01, 10, 30).
  • The M is the month in short text (Jan, Feb, Dec).
  • The y is the year with only two digits (00, 01 17).
  • The H is the time in 24 hour format with zero left (00, 01, 23).
  • The i is the minutes with zero left (00, 01, 59).

  • The - and : are just normal texts.
  • The \a\s is to escape the text as, if you do not use the \ the a would be "exchanged" for am and pm and the s would be "exchanged" for seconds.
  • It worked perfectly, thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.