MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

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 September 30th, 2012, 12:14 PM
rjclancy rjclancy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 1 rjclancy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 43 sec
Reputation Power: 0
Mysql date format

Hi all...

i have a comment script on my website and when a user posts a comment the date shows example Posted :30 september 2012, my date format is %d %b %y...how can i change this to show
Posted : 6 Days ago....

Kind regards

Ronan

Reply With Quote
  #2  
Old September 30th, 2012, 01:17 PM
Rick Grimes Rick Grimes is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 6 Rick Grimes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 29 sec
Reputation Power: 0
i've done something similar before. You dump the date value into php and let your script calculate the difference. i don't guarantee the syntax is perfect since it's just off the top of my head from memory, but something along the lines of this should work :

*** somewhere up here you will have your mySQL recordset. "thePostDate" is assumed to be a standard date/time format***
<?php

$value1 = htmlentities($row_DatabaseRecord['thePostDate']; //gets the date from the database record

$today = time(); // standard function to get today's date

$days_since = ceil(abs($today - $value1) / 86400); // calculates the amount of days since the post, and rounds it to the nearest day

$outputString = "It has been ".$days_since." days since the post."; // creates the report string

echo $outputString;

?>


i highly doubt that's perfect code but all the elements are there. a couple of tweaks and it should work for you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Mysql date format

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap