Current location: Hot Scripts Forums » Programming Languages » PHP » Date difference


Date difference

Reply
  #1 (permalink)  
Old 03-30-09, 12:02 AM
Miben Miben is offline
Wannabe Coder
 
Join Date: Sep 2008
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Date difference

I got booking date such as 2004-03-27 in db table.

How can i calculate the date difference using sql?
i want it return such as:
1 year 2 months ago or
2 month 2 weeks ago or
2 week 3 days ago or
3 days 15 minutes ago or
4 hours ago
15 minutes ago

depend on the difference.

Any idea?
Reply With Quote
  #2 (permalink)  
Old 03-30-09, 03:18 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
You can give TIMESTAMPDIFF() a go, but this isn't something I'd necessarily do with SQL. I'd use PHP in this case.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping Data by Date j-a-m-i-n Database 4 11-21-08 03:47 AM
Date in VB getting format right? budemeadows Visual Basic 6 11-13-08 09:33 AM
date format mysql and php Deansatch PHP 9 03-28-08 04:06 AM
compare date from textbox.. HolyDevil JavaScript 2 11-26-07 01:35 AM
converting date-string to Date object UnrealEd Everything Java 4 05-15-07 06:20 PM


All times are GMT -5. The time now is 08:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.