Jump to content
fil79

[Resolvido] Descobrir a data minima / máxima array

Recommended Posts

fil79

Boas

tenho um array que contem varias datas. Como posso ir buscar a data minima ou máxima contida nesse array? Desde já agradeço


MCITP-MCTS-MCP

Share this post


Link to post
Share on other sites
KiNgPiTo

As funções max/min funcionam para arrays do tipo time, tens é de passar todos os valores para time:

$datesRecorded=array('2012-12-10','2012-12-20');
$tdate = array_map('strtotime', $datesRecorded);

$max = max($tdate);
$min = min($tdate);

echo date('Y-m-j', $max);
echo date('Y-m-j', $min);

Edited by KiNgPiTo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.