473,382 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Time stamps

Does anyone know of a script that translates time stamps to look like
those used by Gmail? (ie. 2 days ago/ 15 minutes ago etc.)

Feb 13 '06 #1
2 1143
KoRnDragon wrote:
Does anyone know of a script that translates time stamps to look like
those used by Gmail? (ie. 2 days ago/ 15 minutes ago etc.)


With time() you can get the current timestamp and then you can calculate
the difference in minutes or days or weeks etc.

Zilla.
Feb 13 '06 #2
function sec2text($secs) {
$units = array(
86400 => 'Days',
3600 => 'Hours',
60 => 'mins',
1 => 'secs' );

$out = '';
foreach($units as $unit => $txt ) {
$t = floor($secs / $unit);
if( $t > 0 ) {
$secs -= ($t * $unit );
$out .= $t . ' ' . $txt . ' ';
}
}
return $out;
}

// behind count
$behind = time() - $take;

sec2text($behind)

-----------------------------------------------------------

Obviously the $take function is the anmount of time your taking away rom the
current time

hope this helps

Stuart
"KoRnDragon" <ko********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Does anyone know of a script that translates time stamps to look like
those used by Gmail? (ie. 2 days ago/ 15 minutes ago etc.)

Feb 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bathroom_Monkey | last post by:
I've got a newb question about Daylight Savings Time (DST). First of all here is some server info: Apache 1.3.28 PHP 4.3.6 MySQL 3.23.49 Time is set to GMT My goal is to be able to...
5
by: RICHARD BROMBERG | last post by:
I am writing an ASP program that includes a Form. When the Form is submitted I use the Date() and Time() functions to put the date and time into the Body part of the e-mail. The time reported is...
4
by: luscus | last post by:
I am trying to device a formula so that when i check of a yes/no box (done) it will automatically add the time in a field called "End Time" and at the same time stamp the amount of minutes...
14
by: George | last post by:
In Time.h there is a structure defined for time settings. I'm building an embedded system that has a Real Time Clock but it's not PC compatible. My question is: I don't some elements of the...
9
by: Bob Achgill | last post by:
I would like to use the timestamp on files to manage the currency of support files for my VB windows application. In this case I would only put the timestamp of the file in the management database...
1
by: bonokoot | last post by:
Hello, I wrote this program in C# that accesses a SQL Server database that runs a stored procedure and sents the results in an email every 30min. I wrote this as a windows application instead of a...
3
The1corrupted
by: The1corrupted | last post by:
No matter what I do, I cannot wrap my head around time stamps... For instance.. $time=$_SERVER; I think that's what it is... at any rate, how can I make a true time stamp with minutes and...
1
by: richardson | last post by:
Hi all i need ur help on how to calculate the avg time of two time stamps like start_time and end_time . The ideal need is to know the average time taken by each job from a table . i tried ...
0
by: =?Utf-8?B?S2VsbHk=?= | last post by:
Each fall and winter I deal witht he same problem. When the daylight savings time comes into effect the time stamp for files on my external portable hard drive are 1 hour out from the time stamps...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.