Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:26:44+00:00 2026-05-14T03:26:44+00:00

Hi i am doing internal mail service application , i have the field called

  • 0

Hi i am doing internal mail service application ,

i have the field called datetime in my table,

i want to show the mail datetim in the inbox view somthing like gmail inbox,

i want to show if the mail came just 10 min aga means , i want to show 10min ago,

if mail came around 2 days back means i want to show the DATE-Time ,

Thing keep in mind i maintain the DATETIME datatyoe ,

Thanks
Bharanikumar

This is snippet i have…

list($date, $time) = explode(‘ ‘, $session_time);

list($year, $month, $day) = explode(‘-‘, $date);

list($hour, $minute, $second) = explode(‘:’, $time);

$session_time = mktime($hour, $minute, $second, $month, $day, $year);

$time_difference = time() – $session_time ;

echo $seconds = $time_difference ;

$minutes = round($time_difference / 60 );

$hours = round($time_difference / 3600 );

$days = round($time_difference / 86400 );

$weeks = round($time_difference / 604800 );

$months = round($time_difference / 2419200 );

$years = round($time_difference / 29030400 );

if($days>2){

echo date(“d-m-Y G:i”,$session_time);

}else

// Seconds

if($seconds <= 60)

{

echo “test$seconds seconds ago”;

}

//Minutes

else if($minutes <=60)

{

if($minutes==1)

{

echo “1 minute ago”;

}

else

{

echo "$minutes minutes ago";

}

}

//Hours

else if($hours <=24)

{

if($hours==1)

{

echo “1 hour ago”;

}

else

{

echo “$hours hours ago”;

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:26:44+00:00Added an answer on May 14, 2026 at 3:26 am

    What you want it what people call Pretty Date. Here is the basic algorithm JavaScript. You should be able to easily port it to PHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When doing an INSERT with a lot of data, ie: INSERT INTO table (mediumtext_field)
When doing an ALTER TABLE statement in MySQL, the whole table is read-locked (allowing
I have a program that makes calls to an internal web API. However when
I have a program that makes calls to an internal web API. However when
Doing odd/even styling with jQuery is pretty easy: $(function() { $(.oddeven tbody tr:odd).addClass(odd); $(.oddeven
When doing small icons, header graphics and the like for websites, is it better
When doing case-insensitive comparisons, is it more efficient to convert the string to upper
When doing TDD , how to tell that's enough tests for this class /
When doing a cvs update , you get a nice summary of the state
I doing a function in Javascript like the VisualBasic DateDiff. You give two dates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.