laplace's demon

Zend Date ile tarih aralığı hesaplamak

by on Apr.02, 2009, under php

çok basit olsa da ben yine de buraya yazıyorum. yapmaya çalışılan kaç yaşında olduğunu hesaplamak.  tek yaptığım da iki timestamp’ı (biri şu anki tarih, diğeri doğum günü) birbirinden çıkartmak. küsüratlı bir rakam elde edilmek istenmiyorsa floor fonksiyonuyla yuvarlana da bilir. bir de 365 e bölmek istenmeyebilir. o ayrı.

$now = new Zend_Date();
$dob = new Zend_Date("954686860", Zend_Date::TIMESTAMP );
echo floor(($now->getTimestamp() - $dob->getTimestamp()) / (24 * 60 * 60)) / 365;
:,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...