Changeset 442 for trunk/Common/Types/DateTime.php
- Timestamp:
- Oct 14, 2012, 9:27:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Types/DateTime.php
r428 r442 11 11 global $MonthNames; 12 12 13 if($Item['Value'] != '') 14 { 15 $ValueParts = explode(' ', $Item['Value']); 16 $DateParts = explode('-', $ValueParts[0]); 17 $TimeParts = explode(':', $ValueParts[1]); 18 19 $Output = ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.$DateParts[0].' '.$TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2]; 20 } else $Output = ''; 13 if(strtolower($Item['Value']) == 'now') $Item['Value'] = time(); 14 $Parts = getdate($Item['Value']); 15 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'].' '. 16 $Parts['hours'].':'.$Parts['minutes'].':'.$Parts['seconds']; 21 17 return($Output); 22 18 } … … 26 22 global $MonthNames; 27 23 28 $ValueParts = explode(' ', $Item['Value']); 29 $DateParts = explode('-', $ValueParts[0]); 30 $TimeParts = explode(':', $ValueParts[1]); 24 if(strtolower($Item['Value']) == 'now') $Item['Value'] = time(); 25 $Parts = getdate($Item['Value']); 31 26 32 27 // Hour … … 34 29 for($I = 1; $I <= 24; $I++) 35 30 { 36 if($ TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';31 if($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 37 32 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 38 33 } … … 42 37 for($I = 1; $I <= 60; $I++) 43 38 { 44 if($ TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';39 if($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 45 40 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 46 41 } … … 50 45 for($I = 1; $I <= 60; $I++) 51 46 { 52 if($ TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';47 if($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 53 48 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 54 49 } … … 58 53 for($I = 1; $I <= 31; $I++) 59 54 { 60 if($ DateParts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';55 if($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 61 56 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 62 57 } … … 66 61 for($I = 1; $I <= 12; $I++) 67 62 { 68 if($ DateParts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';63 if($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 69 64 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 70 65 } … … 74 69 for($I = 1900; $I < 2100; $I++) 75 70 { 76 if($ DateParts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';71 if($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 77 72 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 78 73 } … … 83 78 function OnLoad($Item) 84 79 { 85 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day'].' '. 86 $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']); 80 return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'], 81 $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year'])); 82 } 83 84 function OnLoadDb($Item) 85 { 86 return(MysqlDateTimeToTime($Item['Value'])); 87 } 88 89 function OnSaveDb($Item) 90 { 91 return(date('Y-m-d H:i:s', $Item['Value'])); 87 92 } 88 93
Note:
See TracChangeset
for help on using the changeset viewer.