Created
July 5, 2014 22:42
-
-
Save azeemhassni/d9e48151a7e3cb640a28 to your computer and use it in GitHub Desktop.
function get Custom date String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function customDateString($return = false){ | |
$date = ""; | |
$dayName = date("l"); | |
$dayNumber = date('d'); | |
$monthName = date('F'); | |
$year = date("Y"); | |
$st = array(1,31); | |
$nd = array(2,22); | |
$rd = array(3,23); | |
if(in_array($dayNumber, $st)) { | |
$dayNumber .= "st"; | |
} else if(in_array($dayNumber, $nd)) { | |
$dayNumber .= "nd"; | |
} else if(in_array($dayNumber, $rd)) { | |
$dayNumber .= "rd"; | |
} else { | |
$dayNumber .= "th"; | |
} | |
$date = $dayName.", ".$dayNumber." ".$monthName." ".$year; | |
if($return) return $date; | |
else echo $date; | |
} | |
echo customDateString(TRUE); | |
# output : Sunday, 06th July 2014 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment