Jump to content


Photo

Tempo De Postagem


  • Faça o login para participar
1 reply to this topic

#1 phpnovato

phpnovato

    Turista

  • Usuários
  • 38 posts
  • Sexo:Não informado

Posted 19/09/2011, 22:29

alguém sabe como calculo o tempo de postagem? por exemplo:


postado há 2 minutos atrás;

OU

postado há 8 horas atrás;


OU

postado em 12/4

Edição feita por: phpnovato, 19/09/2011, 22:31.


#2 silici0

silici0

    ?

  • Usuários
  • 902 posts
  • Sexo:Masculino
  • Localidade:São Paulo - SP
  • Interesses:PHP, MySQL, XHTML, CSS, AJAX, JavaScript, Objective-C, Python, Games ... #geek

Posted 21/09/2011, 13:21

So testar:

$date1 = "2008-11-01 22:45:00"; 

$date2 = "2009-12-04 13:44:01"; 

$diff = abs(strtotime($date2) - strtotime($date1)); 

$years   = floor($diff / (365*60*60*24)); 
$months  = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); 
$days    = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));

$hours   = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); 

$minuts  = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); 

$seconds = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minuts*60)); 

printf("%d years, %d months, %d days, %d hours, %d minuts\n, %d seconds\n", $years, $months, $days, $hours, $minuts, $seconds); 

Procurando freelancer
***********************************************
Bachelor of Technology in Technology of Information, with great knowledge in Windows operating systems and Unix-Like (BSD, Ubuntu and Slackware), languages (PHP, JavaScript and MySQL), semantic (DHTML, Tableless, Ajax, MVC, OO) and analysis (manages projects based on PMI).
Developer in PHP, JAVA, Python, Objective-c MySQL, DHTML, CSS, JAVASCRIPT, JQUERY, JSON, SMARTY, MDB2, DOCTRINE, CAKEPHP. Linux desktop for work and MacOS. E-commerces, CRM and bussiness strategys
Love-me and be FREE use UniCes-Like .




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq