Jump to content

finding out days old...


almightyegg

Recommended Posts

Use [url=http://www.php.net/strtotime]strtotime()[/url]

[code=php:0]<?php

$sign_date = "01-11-2006"; // sign-up date in dd-mm-yyyy format
$days = floor((time() - strtotime($sign_date)) / 86400); // 86400 = total seconds in 1 day

echo "You´ve been a member for $days days";

?>[/code]





Or even better, do it directly in your database query. Then you need your dates stored as timestamps... wich you should do when storing dates in your database.

ex:
[code=php:0]SELECT TO_DAYS(CURDATE()) - TO_DAYS(your_date_field) AS days FROM your_table[/code]
Link to comment
https://forums.phpfreaks.com/topic/26606-finding-out-days-old/#findComment-121800
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.