By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Adding 1 second to a timestamp while looping

P: n/a
Hi there,
I'm trying to add 1 second incrementally to a timestamp while looping
through it and I am pulling my hair out.

Please can someone help me?

example of code:

$calc_timestamp =
date('YmdHis',mktime(date('H'),date('i'),date('s')-50,date('m'),date('d'),date('Y')));

This gets the timestamp to be 50 seconds before the time now.

I want to loop through the 50 itmes and add them to a table, but
incremntally increase the timestamp by 1 second and then post it to the
table so that the final item will have the timestamp as at the time of
posting the information

Please help!

Andrew
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
$calc_timestamp++;

--
man man ; man cd; man ls; man bash

fatto non succede nulla

Jul 17 '05 #2

P: n/a
Sathia Musso wrote:
$calc_timestamp++;

i'm sorry, i use linux_timestamp (epoch) and i wrote something wrog indeed.

--
man man ; man cd; man ls; man bash

fatto non succede nulla

Jul 17 '05 #3

P: n/a
I noticed that Message-ID: <cs**********@ctb-nnrp2.saix.net> from Stegga
contained the following:
I want to loop through the 50 itmes and add them to a table, but
incremntally increase the timestamp by 1 second and then post it to the
table so that the final item will have the timestamp as at the time of
posting the information

Please help!


$now=strtotime("now");
for($i=50;$i>0;$i--){
$calc_timestamp =
date('YmdHis',mktime(date('H'),date('i'),date('s', $now)-$i,date('m'),date('d'),date('Y')));
print "$calc_timestamp<br>";
}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

P: n/a
I noticed that Message-ID: <sr********************************@4ax.com>
from Geoff Berrow contained the following:
$now=strtotime("now");
for($i=50;$i>0;$i--){
$calc_timestamp =
date('YmdHis',mktime(date('H'),date('i'),date('s' ,$now)-$i,date('m'),date('d'),date('Y')));
print "$calc_timestamp<br>";
}


oops, make that
for($i=50;$i>-1;$i--){
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5

P: n/a
>> $now=strtotime("now");

why not simply $now = time();?
date('YmdHis',mktime(date('H'),date('i'),date('s', $now)-$i,date('m'),date('d'),date('Y')));


why not simply date('YmdHis',$now--);?
--
* html {redirect-to: url(http://browsehappy.pl);}
Jul 17 '05 #6

P: n/a
*** Stegga wrote/escribió (Wed, 12 Jan 2005 16:35:12 +0200):
$calc_timestamp =
date('YmdHis',mktime(date('H'),date('i'),date('s')-50,date('m'),date('d'),date('Y'))); This gets the timestamp to be 50 seconds before the time now.


$calc_timestamp=time()-50;
while(...){
$calc_timestamp++;
...
}

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #7

P: n/a
I noticed that Message-ID: <opskhxb9szkzdn26@localhost> from porneL
contained the following:
why not simply $now = time();?
date('YmdHis',mktime(date('H'),date('i'),date('s', $now)-$i,date('m'),date('d'),date('Y')));


why not simply date('YmdHis',$now--);?


Um..I was in a hurry?

Yes, that's much neater

<?
$now=time();
for($i=50;$i>-1;$i--){
$calc_timestamp =
date('YmdHis',$now--);
print "$calc_timestamp<br>";
}
?>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.