11.09.2018 Views

Aprender a desarrollar un sitio Web con PHP y MySQL

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

24/4/2014 ENI Training - Libro online<br />

echo strtotime("now").", ".date(’d-m-Y’,strtotime("now")). "";<br />

echo strtotime("10 September 2011").", ".date(’d-m-Y’,strtotime("10<br />

September 2011")). "";<br />

echo strtotime("next Thursday").", ".date(’d-m-Y’,strtotime("next<br />

Thursday")). "";<br />

echo strtotime("last Tuesday").", ".date(’d-m-Y’,strtotime("last<br />

Tuesday")). "";<br />

echo strtotime("+1 day").", ".date(’d-m-Y’,strtotime("+1 day")). "";<br />

echo strtotime("+1 week").", ".date(’d-m-Y’,strtotime("+1 week")).<br />

"";<br />

echo strtotime("+2 week 2 days 2 hours 2 se<strong>con</strong>ds").", ".date(’d-m-y’,<br />

strtotime("+2 week 2 days 2 hours 2 se<strong>con</strong>ds")). "";<br />

?><br />

Da como resultado:<br />

1381822566, 15-10-2013<br />

1315605600, 10-09-2011<br />

1381960800, 17-10-2013<br />

1381183200, 08-10-2013<br />

1381908966, 16-10-2013<br />

1382427366, 22-10-2013<br />

1383215768, 31-10-2013<br />

Por tanto, su sintaxis es:<br />

$timestamp = strtotime($cadena)<br />

La f<strong>un</strong>ción strftime() permite <strong>con</strong>vertir <strong>un</strong>a fecha que tiene la forma de timestamp en <strong>un</strong>a<br />

cadena formateada correctamente. Toma como parámetro el formato de tipo cadena de<br />

caracteres y timestamp como opción, si no quiere la fecha actual. Esta f<strong>un</strong>ción se utiliza<br />

<strong>con</strong>setlocale(), que permite definir el país en el que nos en<strong>con</strong>tramos.<br />

Por ejemplo:<br />

<br />

Da como resultado:<br />

http://www.eni-training.com/client_net/mediabook.aspx?idR=87315 5/7<br />

www.FreeLibros.me

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!