PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 11th, 2008, 03:08 PM
liamdawe liamdawe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Location: England
Posts: 297 liamdawe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 19 m 28 sec
Reputation Power: 3
Send a message via MSN to liamdawe
PHP-General - Work out how many days

Say i have the date "2008-05-06" and i want to find how many days ago that was in php, what is the easiest way?

Reply With Quote
  #2  
Old May 11th, 2008, 03:36 PM
requinix's Avatar
requinix requinix is offline
requinix|on hiatus
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2007
Location: Here
Posts: 2,459 requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)requinix User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 12111 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 6 Days 3 h 11 m 25 sec
Reputation Power: 386
Send a message via MSN to requinix
That looks like something from MySQL...
Is it? Because then you can use the DATEDIFF function:
Code:
SELECT DATEDIFF(NOW(), date) AS `days`



If not, try
PHP Code:
<?php

$then 
strtotime("2008-05-06");
$now time();

$days = ($now-$then)/86400// approximate
// round down using floor(), or round up using ceil()

?>
__________________
Oyashiro-sama...
If something "isn't working" then EXPLAIN WHY. Tell us what it should do, and then what it does do.

PHP Manual (cURL - PCRE regex - references) error_reporting() SQL injection: and mysql_real_escape_string() PHP and cron
Negative0

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Work out how many days


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway