Last active
December 10, 2015 13:38
-
-
Save bsalim/4441755 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Format date using PHP DateTime Object | |
**/ | |
function format_date_from_mysql($date,$newformatted='M d, Y') | |
{ | |
return DateTime::createFromFormat("Y-m-d H:i:s", $date)->format($newformatted); | |
} | |
/** | |
* Take mysql date format and display it nicely like a calendar format | |
**/ | |
function nice_display_date($date,$time=false) | |
{ | |
if($time) { | |
$string = '<div style="text-align:center">'; | |
$string .= '<span style="font-size:16px;font-weight:700;color:#999">'.format_date_from_mysql($date,'g:i A').'</span>'; | |
$string .= '</div>'; | |
return $string; | |
} | |
$string = '<div style="text-align:center">'; | |
$string .= '<span style="font-size:16px;font-weight:700;color:#999">'. | |
format_date_from_mysql($date,'M').'</span><br />'; | |
$string .= '<span style="font-size:26px;font-weight:700;color:#f90">'. | |
format_date_from_mysql($date,'d').'</span><br />'; | |
$string .= '<span style="font-size:14px;font-weight:700;">'. | |
format_date_from_mysql($date,'Y').'</span>'; | |
$string .= '</div>'; | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment