Search code examples
phpsubstr

Convert PHP Date substring "month" date format to uppercase


I have a PHP code that outputs the alphabetical value of the month of the year and then I substring the value to show only the last letter i.e:<?php echo substr(date("M"),2);?>

It works well but the only problem is the result is in lowercase. The result i get is "g" in the case of "Aug" instead of "G".

Can someone help with a code snippet to do this? I would really appreciate it.

Thanks in advance, Ralph.


Solution

  • Using strtoupper the output will be as you expected:

    <?php echo strtoupper(substr(date("M"),2));?>