[thelist] SQL Server DateTime Format

Burhan Khalid burhankhalid at members.evolt.org
Tue Jun 18 11:42:01 CDT 2002


You didn't specify a language -- so I'll shoot some code in PHP :

$str_dateTime = "6/18/02 9:20:22 AM"; //Original Date Time
list($str_date,$str_time,$str_ampm) = $explode (" ",$str_dateTime); //
get parts
list($int_hour,$int_minutes,$int_secs) = $explode(":",$str_time); // get
parts of time
if (((int)$int_hour) < 10) {
	$str_formattedTime = $str_date." 0".$int_hour.$int_minutes;
} else { $str_formattedTime = $str_date." "$int_hour.$int_minutes; }

hth,
Burhan





More information about the thelist mailing list