Ver Mensaje Individual
  #5 (permalink)  
Antiguo 20/03/2013, 13:01
cachusan
 
Fecha de Ingreso: septiembre-2011
Mensajes: 219
Antigüedad: 12 años, 7 meses
Puntos: 31
Respuesta: como comparar fechas en javascript

Cita:
Iniciado por by_antun Ver Mensaje
<?php
$resultado= mysql_query ("SELECT fecha_cotizacion FROM cotizacion");
$result = mysql_result($resultado);
$fecha = date("Y-m-d");
if ($fecha > $result)
{
echo "Favor modificar cotizacion";
header("location:cotizacion.php");
else
{
header("location:welcome.php");
}
?>
Eso es php, en javascript lo podrías hacer de este modo:

Código PHP:
Ver original
  1. <script type="text/javascript">
  2.  
  3. var current_date = new Date();
  4. var full_mysql_date = "<?php echo $mi_fecha_de_la_base; ?>";
  5. var mysqldate_parts = full_mysql_date.split("-");
  6. var mysqldate = new Date(mysqldate_parts[0], mysqldate_parts[1] - 1, mysqldate_parts[2]);
  7.  
  8. if(current_date >=  mysqldate){
  9.   window.location.href = 'archivo.php';
  10. }else{
  11.   alert('mensaje');
  12. }
  13.  
  14. </script>