Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

need help with Time function

General discussions related to php

Moderators: macek, egami, gesf

need help with Time function

Postby slayn27 » Tue Jul 31, 2012 7:21 pm

I am making a forum and my problem is I need codes to determine how many years,months,days old the post is.

Thanks in advance :)
slayn27
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Jul 08, 2012 8:07 pm

Re: need help with Time function

Postby freshnet » Wed Aug 01, 2012 5:21 am

As always, let us know what code you have and what point you are stuck at. You will need to record the forum post date/time in a database.
User avatar
freshnet
php-forum Active User
php-forum Active User
 
Posts: 252
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: need help with Time function

Postby slayn27 » Fri Aug 03, 2012 5:38 pm

sorry for the late reply sir..I already have a database.. I need a sample code for subtracting time and instead of "mm/dd/yy" format i want to display it in total days or totalmonths or totalyears
slayn27
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Jul 08, 2012 8:07 pm

Re: need help with Time function

Postby johnj » Fri Aug 03, 2012 7:25 pm

pseudo code:
Code: Select all
1.get the posted date
2. get todays' date
3.get the difference between 1 and 2
4.convert the difference to seconds
5.Now, the convert the difference to months or days or years


This article may help you to some extent:
http://phillipnb.wordpress.com/2012/04/ ... ds-in-php/
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron