• 0

A better time display functionset


Question

Hey everyone. It's been awhile since I've been heavily active on Neowin, but I thought I'd post this here anyway. I couldn't find this particular set of functions online anywhere, so I wrote them myself. It untilizes epoch timestamps generated from the PHP time() function.

<?php
function CoolTimeRep($now, $compare){
$difference = $now - $compare;

$minutes = round($difference / 60);
$hours = round($difference / 3600);
$days = round($difference / 86400);
$weeks = round($difference / 604800);
$years = round($difference / 31449600);

	if($years != 0){return $years . " year".plural($years)." ago";}

	elseif($weeks != 0){return $weeks . " week".plural($weeks)." ago";}

	elseif($days != 0){return $days . " day".plural($days)." ago";}

	elseif($hours != 0){return $hours . " hour".plural($hours)." ago";}

	elseif($minutes != 0){return $minutes . " minute".plural($minutes)." ago";}

	else{return "just now";}

}

function plural($var){
if($var < "2"){$nothing;}
else{return "s";}
}
?>

Link to comment
https://www.neowin.net/forum/topic/445166-a-better-time-display-functionset/
Share on other sites

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Microsoft changed recall to opt-in some time ago, which seems to still be the case. I personally feel like that is the right move for something like this. You are right, settings that turn themselves back on after an update is totally unacceptable; its weird how that only happened with privacy and advertising related settings...
    • I have a Tab S9 FE and a Tab A9+ which is a lot less expensive. I much prefer the TabA9+. 1. Its display is more landscape while that of the S9 FE is more boxy. 2. They both drain battery at about the same rate of between 7% and 9% an hour depending on how I use them 3. The Tab A9+ charges a lot faster than S9 FE, The S9 FE is better at handling memory, It is faster. They both have 8GB. The TabA9+ does a lot better at handling memory on Android 15, One UI 7.0 than it did on Android 14, One UI 6.1
    • Following rough launch, Splitgate 2 is going back to beta as studio announces layoffs by Pulasthi Ariyasinghe The sequel to the free-to-play arena shooter Splitgate was released just a couple of months ago alongside a surprise Battle Royale mode, but it doesn't look like the launch has gone too well for the studio, 1047 Games. In a lengthy social media post, the developer revealed that it is making some major changes within the company that will also affect its games. The studio said that it agrees with the community regarding Splitgate 2 launching too early with rushed features. Because of this, the title is returning to its beta state. While Splitgate 2 will remain playable, the studio will be deep in development reworking the title behind the scenes until at least early 2026. The soon-landing Season 3 content update is still planned for release. "We're returning not just to our roots in what we build, but in how we build it – with you," said the company. "That means more playtests, more surveys, more listening, and truly being community first. Our goal is to combine the DNA of the first game with the best improvements from the second." The studio also revealed that this shakeup means that it had to cut some team members from the studio. It didn't give an exact number for the roles being cut but said that "we hope to bring them back when we can." In the same vein of keeping costs low, 1047 Games will be shutting down the servers for the original Splitgate within a month's time. "While we'd love to keep servers online indefinitely, it's cost us hundreds of thousands of dollars over the past couple of years, and we have to prioritize our team," added the studio. It said that offline play or peer-to-peer matchmaking for Splitgate are being explored for fans to keep playing, but nothing concrete about these potential options was announced today.
    • It sounds like you are referring to the hidden div scandal, which due to an architectural limitation on Edge prevented hardware acceleration, but of course Google denied that it was specifically intended to break Edge, which of course I don't believe. Google is known for that kind of evilness. The hidden div was also being served to Chrome in that case, but it had a different method that didn't break hardware acceleration.
    • I guess we can agree to disagree. I had the completely opposite experience, and not just that it annoyed me, I was frequently unable to use the sites I visited regularly.
  • Recent Achievements

    • Week One Done
      SmileWorks Dental earned a badge
      Week One Done
    • Community Regular
      vZeroG went up a rank
      Community Regular
    • Collaborator
      Snake Doc earned a badge
      Collaborator
    • Week One Done
      Snake Doc earned a badge
      Week One Done
    • One Month Later
      Johnny Mrkvička earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      587
    2. 2
      Michael Scrip
      199
    3. 3
      ATLien_0
      193
    4. 4
      +FloatingFatMan
      133
    5. 5
      Xenon
      122
  • Tell a friend

    Love Neowin? Tell a friend!