Forum Moderators: coopster

Message Too Old, No Replies

Year / Month / Day / Hour / Minutes Posted Date

tum tum ....

         

scriptmasterdel

2:27 pm on Mar 28, 2006 (gmt 0)

10+ Year Member



I am creating a forum and a while back i saw a forum with a nifty "posted 12days 14hours and 6minutes ago"

I am currently using dd-mm-yyyy format dates in my datasbase table.

> HOW IS THIS CONVERTED? Is my question.

If you can help me, i would be so gratefull!

Cheers,
Del

coopster

4:05 pm on Mar 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What is the column type? I'm guessing it is not of type DATE.

scriptmasterdel

8:10 am on Mar 29, 2006 (gmt 0)

10+ Year Member



I have set it as varchar(20), do you recommend setting it to date?

Thank you for your quick reply.

omoutop

8:16 am on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can set it to date format OR to integer format (and save unix/epoch time).

Personally i preer the second option; it's easier to do math calculations with integer than with dates... but i guess its all a matter of habits :)

scriptmasterdel

8:39 am on Mar 29, 2006 (gmt 0)

10+ Year Member



So from this, how would i convert the time in to past time? Like i asked in my first question?

Thanks Omoutop!

omoutop

9:51 am on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



lets say that :
$old_date="2006-12-31";
$a = explode("-",$old_date);
$old_date_to_check = mktime(0,0,0,$a[1],$a[2],$a[0]); // this will give you the date you want to check as unix time

sql = " select * from table where time_field>'$old_date_to_check' "

the above example works if your time_field is an integer.

i cant ofer help in date format - never used it :)