473,786 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding 1 second to a timestamp while looping

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',m ktime(date('H') ,date('i'),date ('s')-50,date('m'),da te('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
7 4702
$calc_timestamp ++;

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

fatto non succede nulla

Jul 17 '05 #2
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
I noticed that Message-ID: <cs**********@c tb-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',m ktime(date('H') ,date('i'),date ('s',$now)-$i,date('m'),da te('d'),date('Y ')));
print "$calc_timestam p<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
I noticed that Message-ID: <sr************ *************** *****@4ax.com>
from Geoff Berrow contained the following:
$now=strtotime ("now");
for($i=50;$i>0 ;$i--){
$calc_timestam p =
date('YmdHis', mktime(date('H' ),date('i'),dat e('s',$now)-$i,date('m'),da te('d'),date('Y ')));
print "$calc_timestam p<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
>> $now=strtotime( "now");

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


why not simply date('YmdHis',$ now--);?
--
* html {redirect-to: url(http://browsehappy.pl) ;}
Jul 17 '05 #6
*** Stegga wrote/escribió (Wed, 12 Jan 2005 16:35:12 +0200):
$calc_timestamp =
date('YmdHis',m ktime(date('H') ,date('i'),date ('s')-50,date('m'),da te('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
I noticed that Message-ID: <opskhxb9szkzdn 26@localhost> from porneL
contained the following:
why not simply $now = time();?
date('YmdHis',m ktime(date('H') ,date('i'),date ('s',$now)-$i,date('m'),da te('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_timestam p<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8280
by: kbrad | last post by:
I am uploading files to my webserver using an asp upload script and would like to add a timestamp just before they are saved to the server. This would mean that filename.txt on my server would be uploaded to the webserver as filenameYYMMDDhhmmss.txt or something similar. Can anyone advise how to do this?
2
2888
by: Craig Keightley | last post by:
How do i display a date as a new column 7 days after the initial timestamp eg current timestamp = 20050310000000 if i add 7 days to this won't it result in 20050317000000 eg SELECT *, DATE_FORMAT('%d/%m/%Y' , (dateAuthorised+7)) as expiryDate I know this is the wrong approach as the timestamp 20050330000000 would cause an error
2
5185
by: rong.guo | last post by:
Hello Group, I am having a really weird problem... Can anyone tell the difference between Query 1 and Query 2 below? Why Query 2 excludes '2/28/2005'? Many thanks! create table a (ApplicationID int ,timestamp datetime)
2
4372
by: Russell Smith | last post by:
Timestamps support infinity. However if appears dates do not. When timestamps are cast to dates, there is no output. Is this an acceptable option or not? Below are a number of examples showing what I am experiencing. The last own shows how converting timestamps to dates and then ordering doesn't give you the order you want. Maybe you should just order by the timestamp to begin with. However Date does not understand infinity at all.
9
4045
by: Daniel Vukadinovic | last post by:
I want to implement an index/counter to my linked list. Why? I wrote a search function which searches the list for elements based on their values (say I add an element and I assign the value 54 and the next element 789 and so on...) now I'd like to write a search function which would search the list for elements based on their index. Say first element is 54 and index 1, second element is 789 and index 2 so when I want to search, I'll do...
5
1512
by: Justin Fancy | last post by:
Hi everyone, I need some help. I'm placing text files into a created database using vb.Net. The problem is that, i need two seperate sql statements to add both files because they are in different loops. My output comes out to be as Follows: TABLE ---------------------------------------------------- Field1 Field2
6
11082
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
9
175
by: =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= | last post by:
``odict.byindex(index)`` For this API, I think it's important to make some performance guarantees. It seems fairly difficult to make byindex O(1), and simultaneously also make insertion/deletion better than O(n). IOW, the PEP should somehow specify which operations are efficient, and which ones aren't. Regards,
10
2496
by: Guillermo_Lopez | last post by:
Hello All, I am using VBA in access to perform some calculations. There is a particular sumation that is wrong (barely). this code is withing a loop. TDist = TDist + TempDist Both TDist and TempDist are declared as doubles:
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.