Browse Source

Fixed thew date issue

ravenlp 18 years ago
parent
commit
5184069b5f
1 changed files with 16 additions and 4 deletions
  1. 16 4
      classes/mysql_connection.class.php

+ 16 - 4
classes/mysql_connection.class.php View File

103
 			$sqlValues .= "$valor,";
103
 			$sqlValues .= "$valor,";
104
 		 }
104
 		 }
105
 		 elseif (substr_count(MYSQL_TYPES_DATE, "$tipo_col ")) {
105
 		 elseif (substr_count(MYSQL_TYPES_DATE, "$tipo_col ")) {
106
+		 	echo "<h2>$valor | $tipo_col</h2>";
106
 			$valor = $this->formatearFecha($valor, $tipo_col); // formatea las fechas
107
 			$valor = $this->formatearFecha($valor, $tipo_col); // formatea las fechas
108
+			
107
 			$sqlValues .= "'$valor',";
109
 			$sqlValues .= "'$valor',";
108
 		 }
110
 		 }
109
 		 elseif (substr_count(MYSQL_TYPES_STRING, "$tipo_col ")) {
111
 		 elseif (substr_count(MYSQL_TYPES_STRING, "$tipo_col ")) {
115
 	  $sqlValues = rtrim($sqlValues, ',').')';     
117
 	  $sqlValues = rtrim($sqlValues, ',').')';     
116
 	  
118
 	  
117
 	  // inserta los valores en la DB	  
119
 	  // inserta los valores en la DB	  
118
-	  $sql = "INSERT INTO $tabla $cols VALUES $sqlValues";	  
120
+	  $sql = "INSERT INTO $tabla $cols VALUES $sqlValues";	
121
+	  echo $sql;  
119
 	  return $this->ejecutarConsulta($sql);	  
122
 	  return $this->ejecutarConsulta($sql);	  
120
 	}
123
 	}
121
 	
124
 	
199
 	 * @return date Fecha para insertar en la BD.
202
 	 * @return date Fecha para insertar en la BD.
200
 	 */
203
 	 */
201
 	function formatearFecha($valor) {
204
 	function formatearFecha($valor) {
202
-	  
203
-	  if (gettype($valor) == 'string') $valor = strtotime($valor);
205
+	  	if(!eregi("^.{4}\-.{2}\-.{2}\ .{2}\:.{2}\:.{2}$",$valor)){
206
+			if(eregi("^([0-9]+)$",$valor)){
207
+				$valor = date("Y-m-d H:i:s",$valor);
208
+			}else{
209
+				// Estariá en el formato strtotime()
210
+				$valor = date("Y-m-d H:i:s",strtotime($valor));
211
+			}
212
+		}
213
+		echo "<h4>($valor)</h4>";
214
+		return $valor;
215
+	/*  if (gettype($valor) == 'string') $valor = strtotime($valor);
204
 	  return date('Y-m-d H:i:s', $valor);
216
 	  return date('Y-m-d H:i:s', $valor);
205
-	
217
+	*/
206
 	}
218
 	}
207
 	
219
 	
208
 	/**
220
 	/**