View Source
/hsphere/local/home/c251266/sunsetvines.com/www.sunsetvines.com/sunsetvines/current/vendor/creovel/helpers/datetime.php (1.103 KB)
#0001
#0002
#0003
#0004
#0005
#0006
#0007
#0008
#0009
#0010
#0011
#0012
#0013
#0014
#0015
#0016
#0017
#0018
#0019
#0020
#0021
#0022
#0023
#0024
#0025
#0026
#0027
#0028
#0029
#0030
#0031
#0032
#0033
#0034
#0035
#0036
#0037
#0038
#0039
#0040
#0041
#0042
#0043
#0044
#0045
#0046
#0047
#0048
#0049
#0050
#0051
#0052
#0053
#0054
#0055
#0056
#0057
#0058
#0059
#0060
#0061
#0062
#0063
#0064
#0065
#0066
#0067
#0068
#0069
#0070
#0071
#0072
#0073
#0074
|
<?php /** * Returns MySQL Timestamp. * * @author Nesbert Hidalgo * @param mixed $datetime optional * @return string */ function datetime($datetime = null) {
switch ( true ) { case ( !$datetime ): default: return date('Y-m-d H:i:s'); break;
case ( is_array($datetime) ): return date('Y-m-d H:i:s', mktime(military_hour($datetime['hour'], $datetime['ampm']), $datetime['minute'], $datetime['second'], $datetime['month'], $datetime['day'], $datetime['year'])); break; case ( is_numeric($datetime) ): return date('Y-m-d H:i:s', $datetime['year']); break; case ( is_string($datetime) ): return date('Y-m-d H:i:s', strtotime($datetime)); break; } }
/** * Returns Military hour equivalent. * * @author John Faircloth * @param int $hour * @param str $ap */
function military_hour($hour, $ap) {
if ( $ap == 'PM' || $ap == 'pm') { if ($hour == 12) { $return_hour = 12; } else { $return_hour = $hour + 12; } } else { if ($hour == 12) { $return_hour = 0; } else { $return_hour = $hour; } }
return $return_hour;
} ?>
|