473,407 Members | 2,359 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,407 software developers and data experts.

Time + 10 minutes

$ganja=date("D dS M h:i A");
Assuming the above produced the following .

Tue 02nd Jan 11:55 PM
How do i add 10 minutes to it to produce this ? .

Wed 03rd Jan 00:05 AM

Jan 4 '07 #1
10 6616
Message-ID: <MP************************@news.newsreader.comfro m
Krustov contained the following:
>$ganja=date("D dS M h:i A");
Assuming the above produced the following .

Tue 02nd Jan 11:55 PM
It would produce the current time
>

How do i add 10 minutes to it to produce this ? .

Wed 03rd Jan 00:05 AM
$ganja=date("D dS M h:i A",time()+600);

--
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/
Jan 4 '07 #2
<comp.lang.php>
<Geoff Berrow>
<Thu, 04 Jan 2007 17:18:20 +0000>
<ke********************************@4ax.com>
$ganja=date("D dS M h:i A",time()+600);
That worked fine - thanks to both users .
--
www.phptakeaway.co.uk
(work in progress)
Jan 4 '07 #3
Krustov wrote:
$ganja=date("D dS M h:i A",time()+600);

That worked fine - thanks to both users .
Or, if you're like me and don't want to figure out the correct number
to add for various intervals, a more plain-english style solution would
be:
$ganja = date("D dS M h:i A",strtotime("+10 minutes"));

Jan 4 '07 #4
Rik
David Gillen wrote:
Moot said:
>Krustov wrote:
>>>$ganja=date("D dS M h:i A",time()+600);
That worked fine - thanks to both users .

Or, if you're like me and don't want to figure out the correct number
to add for various intervals, a more plain-english style solution
would be:
$ganja = date("D dS M h:i A",strtotime("+10 minutes"));
Haha, I like that. Anything that makes something easier to understand
when scanning the code is good.
Well strtotime has it's advantages. However, it's poorly documented and
sometimes unpredictable. After a short while I reverted back to working
with adding/subtracting timestamps, just with a comment in the code beside
it. Equally (or even more) clear thans to the comment, and 100%
predictable.
--
Rik Wasmus
Jan 4 '07 #5
Message-ID: <cd***************************@news2.tudelft.nlfro m Rik
contained the following:
>>$ganja = date("D dS M h:i A",strtotime("+10 minutes"));
Haha, I like that. Anything that makes something easier to understand
when scanning the code is good.

Well strtotime has it's advantages. However, it's poorly documented and
sometimes unpredictable. After a short while I reverted back to working
with adding/subtracting timestamps, just with a comment in the code beside
it. Equally (or even more) clear thans to the comment, and 100%
predictable.
I've had the same experience. And if you really can't work out the
number of seconds in ten minutes, let the code do the work

$ganja=date("D dS M h:i A",time()+(60*10));

Personally though I'd rather keep things that I may want to change
elsewhere, so:

$delay=600;
//this can be in a config file and commented
....
$ganja=date("D dS M h:i A",time()+$delay);

--
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/
Jan 5 '07 #6
..oO(Rik)
>Well strtotime has it's advantages. However, it's poorly documented and
sometimes unpredictable. After a short while I reverted back to working
with adding/subtracting timestamps, just with a comment in the code beside
it. Equally (or even more) clear thans to the comment, and 100%
predictable.
Yep, but in some cases you have to be very careful when doing date/time
calculations by hand. Daylight saving time can be an issue for example.

Micha
Jan 5 '07 #7
Rik wrote:
David Gillen wrote:
Moot said:
Krustov wrote:
$ganja=date("D dS M h:i A",time()+600);
That worked fine - thanks to both users .
Or, if you're like me and don't want to figure out the correct number
to add for various intervals, a more plain-english style solution
would be:
$ganja = date("D dS M h:i A",strtotime("+10 minutes"));
Haha, I like that. Anything that makes something easier to understand
when scanning the code is good.

Well strtotime has it's advantages. However, it's poorly documented and
sometimes unpredictable. After a short while I reverted back to working
with adding/subtracting timestamps, just with a comment in the code beside
it. Equally (or even more) clear thans to the comment, and 100%
predictable.
--
Rik Wasmus
Agreed. strtotime has some annoying flaws that aren't officially
documented. For an illustration, try the following code:
<?php
echo date('m/d/Y', strtotime('3/31/2006')) . " - Today\n";
echo date('m/d/Y', strtotime('-1 month', strtotime("3/31/2006"))) . " -
Last Month (expect: 2/??/2006)\n";
echo date('m/d/Y', strtotime('+1 month', strtotime("3/31/2006"))) . " -
Next Month (expect: 4/??/2006)\n";
?>

This example shows how strtotime's handling of months could really
screw up logic expecting it to work in a different way than it actually
does (I should know, I've learned it the hard way). Since there are 28
days in Feb, strtotime adds the 3 extra days (to 31) and ends up at
March 3rd, similar problem with April, which has 30 days, so the extra
1 puts it to May 1st.

I've only really had a problem with strtotime with months, though.
Most other time intervals seem to work as expected.

- Moot

Jan 5 '07 #8
..oO(Moot)
>Agreed. strtotime has some annoying flaws that aren't officially
documented. For an illustration, try the following code:
[...]

This example shows how strtotime's handling of months could really
screw up logic expecting it to work in a different way than it actually
does (I should know, I've learned it the hard way). Since there are 28
days in Feb, strtotime adds the 3 extra days (to 31) and ends up at
March 3rd, similar problem with April, which has 30 days, so the extra
1 puts it to May 1st.
This behaviour is documented:

| The fuzz in units can cause problems with relative items. For example,
| `2003-07-31 -1 month' might evaluate to 2003-07-01, because 2003-06-31
| is an invalid date. To determine the previous month more reliably, you
| can ask for the month before the 15th of the current month. [...]

http://www.gnu.org/software/tar/manu...15.html#SEC115

Micha
Jan 6 '07 #9
Rik
Michael Fesser wrote:
.oO(Moot)
>Agreed. strtotime has some annoying flaws that aren't officially
documented. For an illustration, try the following code:
[...]

This example shows how strtotime's handling of months could really
screw up logic expecting it to work in a different way than it
actually does (I should know, I've learned it the hard way). Since
there are 28 days in Feb, strtotime adds the 3 extra days (to 31)
and ends up at March 3rd, similar problem with April, which has 30
days, so the extra 1 puts it to May 1st.

This behaviour is documented:
>The fuzz in units can cause problems with relative items. For
example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because
2003-06-31 is an invalid date. To determine the previous month more
reliably, you can ask for the month before the 15th of the current
month. [...]

http://www.gnu.org/software/tar/manu...15.html#SEC115
Yup, this is actually not one of the things I would qualify as
unpredictable behviour, yet it's understandable that with a syntax like
strtotime people understand it to work.

In the same ballpark of unexpected yet highly logical behaviour:

echo date('r',mktime(0,0,0,0,0,2007));

Unexpected for most, but highly logical nonetheless ;)
--
Rik Wasmus
Jan 6 '07 #10
..oO(Rik)
>In the same ballpark of unexpected yet highly logical behaviour:

echo date('r',mktime(0,0,0,0,0,2007));

Unexpected for most, but highly logical nonetheless ;)
Nice example. ;)

Micha

PS: But still documented ... SCNR
Jan 6 '07 #11

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

Similar topics

15
by: kpp9c | last post by:
I am kind of in a bit of a jam (okay a big jam) and i was hoping that someone here could give me a quick hand. I had a few pages of time calculations to do. So, i just started in on them typing...
0
by: SimonC | last post by:
I'm looking to do something similar to a feature found on Ticketmaster.com, where you select your seats at a venue, and then you have two minutes in which to take or leave them. QUESTION 1a....
3
by: John McGinty | last post by:
Hello Chaps, Just a little sounding on removing out of hours from some datetime date that I have. Basically we have a helpdesk that logs calls when they are entered and when they are resolved....
4
by: flupke | last post by:
Is there an easy to convert following hour notation hh:mm to decimals? For instance 2 hours and 30 minutes as 2:30 to 2,50 I don't really know where to search for this kind of conversion. ...
6
by: Michael Bulatovich | last post by:
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time",...
2
by: x | last post by:
hi i am a pilot by profession. i want to create a database of my logbook using ms access 2002. i am facing a problem regarding the format of time field. when i select "Data/Time" data type for my...
22
by: Drum2001 | last post by:
I have a table that tracks employee times. I have a column (Date/Time). Users, through a form, enter how long it takes them to complete a task. For example, 03:45 = 3 hours and 45 mins. I am...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
3
by: RN1 | last post by:
A Form has 2 TextBoxes where in users enter date & time. Example (in mm/dd/yyyy format): 09/20/2008 17:54 (1st TextBox) 09/29/2008 6:13 (2nd TextBox) How do I find out how much time (in...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
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: 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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.