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:
  #1  
Old May 11th, 2008, 03:08 PM
liamdawe's Avatar
liamdawe liamdawe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Location: England
Posts: 483 liamdawe User rank is Sergeant (500 - 2000 Reputation Level)liamdawe User rank is Sergeant (500 - 2000 Reputation Level)liamdawe User rank is Sergeant (500 - 2000 Reputation Level)liamdawe User rank is Sergeant (500 - 2000 Reputation Level)liamdawe User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 9 h 17 m 42 sec
Reputation Power: 9
Send a message via MSN to liamdawe Send a message via Google Talk 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
No strings attached
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 4,625 requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)requinix User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 77202 Folding Title: Intermediate FolderFolding Points: 77202 Folding Title: Intermediate FolderFolding Points: 77202 Folding Title: Intermediate FolderFolding Points: 77202 Folding Title: Intermediate Folder
Time spent in forums: 3 Months 3 Weeks 3 Days 20 h 5 m 32 sec
Reputation Power: 1898
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()

?>
__________________
How to ask a question

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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT