PHP Convert MySQL Timestamp to Ago Format: OOP Class Tutorial Object Oriented Programming




Learn how to program OOP in PHP and convert MySQL timestamp to the “Ago” format. Using a PHP class. Get the Zip Download Package Here: …

Original source


26 responses to “PHP Convert MySQL Timestamp to Ago Format: OOP Class Tutorial Object Oriented Programming”

  1. $periods=array("sec","min","hr","day","week","month","year","decade")
    $lengths=array("60","60","24","7","4.35","12","10");
    Here $periods.length = 8 and $lengths.length =7
    then how can we compare it thats why I am receiving error when calculating sec and min ago. Adam ! Am I right . Please suggest me.

    Thanks

  2. This worked amazing, Thank you very much!
    But, Sir, had a small question. How can we put time as shown below, if more than a minute?
    Example:
    20 mins & 13 secs ago
    – or –
    20 days & 8 hours ago

    This might really help in a long run when it comes to months and years. Because i suppose if a message or a user is 1 year & 11 months old it will still show "1 year ago".

  3. @Huda6000 you probably figured it by now, but for others! You put the php code before header tags and in the context of the page where ago should go, just echo the when variable between php brackets!

  4. Heloo Adam, your videos are amazing it help me a lot…this ago script works perfectly in my website.. but i need 'time left' code too… like 2 days ago – 2 month left.. i tried but fail.. i need help 🙁

  5. If you are using phpmyadmin,

    1) You have to change your php.ini

    date.timezone = 'put correct time zone here'

    Example:
    date.timezone = 'Asia/Ho Chi Minh'

    you can find a list of supported time zones at:
    us2.php.net/manual/en/timezones.php

    2) You have to change the timezone in your mysql, this can be done a number of ways, google it and read

    Example:
    mysql_query("SET SESSION time_zone = 'enter timezone'");
    OR
    SET time_zone = 'enter timezone';
    OR
    date_default_timezone_set

  6. Great tutorial 5/5 or 1thumb up LOL idk but i think another good tutorial would be how u made that very nice chatroom in flash i havent figured out how to make action script code to make an online user …thigy lol for lack of a better word

  7. @flashbuilding Naw I don't think so at all. It would make my web apps cleaner and more powerful. I'd love to go a little further. You're awesome. Just thought you'd like to know I also got a call from a client on web intersect 😉

Leave a Reply