Demo entry 5469121

PHP: Operaciones con fechas

   

Submitted by anonymous on Jun 26, 2016 at 20:04
Language: PHP. Code size: 500 Bytes.

<?php
$dt_Ayer= date('Y-m-d', strtotime('-1 day')) ; // resta 1 día
$dt_laSemanaPasada = date('Y-m-d', strtotime('-1 week')) ; // resta 1 semana
$dt_elMesPasado = date('Y-m-d', strtotime('-1 month')) ; // resta 1 mes
$dt_ElAnioPasado = date('Y-m-d', strtotime('-1 year')) ; // resta 1 año
//Mostrar fechas

echo $dt_Ayer;
echo $dt_laSemanaPasada;
echo $dt_elMesPasado;
echo $dt_ElAnioPasado;
/*
Resultado (fecha actual: 2012-09-18):
2012-09-17
2012-09-11
2012-08-18
2011-09-18
*/
?>

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).