php-general | 2005051
Date: 05/04/05
- Next message: Jason Barnett: "[PHP] Re: Error suppression operator (@)"
- Previous message: Phil Ewington - 43 Plc: "[PHP] xslt_process() error"
- In reply to: Ryan A: "[PHP] age function"
- Next in thread: Mark Cain: "Re: [PHP] age function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tuesday 03 May 2005 22:41, Ryan A wrote:
> Hey,
> Anybody have an age function where i can pass a date object and get back an
> int?
>
> eg:
> $years_old=get_years("1979-12-07");
Use time and mktime.
$birthday = ""1979-12-07";
$birdthday_time = mktime(0, 0, 0, substr($birthday, 5, 2), substr($birthday,
8, 2), substr($birthday, 0, 4));
$now_time = time();
$years = (int) (($now_time - $birthday_time) / 60*60*24*365.25);
I haven't tested the code - it's just an idea.
>
> Thanks,
> Ryan
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005
--Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-)
PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
- application/pgp-signature attachment: stored
- Next message: Jason Barnett: "[PHP] Re: Error suppression operator (@)"
- Previous message: Phil Ewington - 43 Plc: "[PHP] xslt_process() error"
- In reply to: Ryan A: "[PHP] age function"
- Next in thread: Mark Cain: "Re: [PHP] age function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

