Hello all,
i am writing a tiny program as an excersize to take someones age and determine how many seconds old they are. This is the php to what i have so far: -
<?php
-
-
$action = $_POST['action'];
-
$name= $_POST['name'];
-
$month=$_POST['month'];
-
$day= $_POST['day'];
-
$year= $_POST['year'];
-
$time= $_POST['time'];
-
$m= ("$month,$day");
-
$calculate= "$month, $day, $year, $time";
-
-
?>
-
-
<?php
-
echo("Hello, $name ! ");
-
echo("You were born on $month $day, $year at $time o'clock".'</br>');
-
echo('you are ');
-
echo time() - strtotime ("$m, $year, $time, $year");
-
echo (' seconds old!');
-
-
-
?>
-
The problem is that it doesnt calculate properly. I think this line: echo time() - strtotime ("$m, $year, $time, $year");
is the problem, i just dont know how to fix it. Please help!!!!
Thanks,
6 1592
Heya, Wadro. Welcome to TSDN!
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
here is the out put:
Hello, ! You were born on jun 18, 1982 at 11:00 o'clock
you are 1187893914 seconds old!
The seconds that are calculating (1187893914) are wrong. as i refresh the screen the seconds are updated they just dont have the write answer. i dont know were it gets the 1187893914 from.
Thanks,
Heya, Wadro.
I'll bet that your script is outputting the number of seconds since December 31, 1969 11:59:59.
Try this instead: -
echo time() - strtotime("$year-$month-$day $time");
-
Heya, Wadro.
I'll bet that your script is outputting the number of seconds since December 31, 1969 11:59:59.
Try this instead: -
echo time() - strtotime("$year-$month-$day $time");
-
Thats it! Thanks for quick reply!
below is the entire code for anyone who is interested. It's a very small app but good to play with. Atli 5,058
Expert 4TB
Hi.
Have you considered calculating the seconds manually, instead of using the strtotime() function?
Edit: on second thought, thats the long way around. Your way is better :)
Heya, Wadro.
Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Graham |
last post by:
I have a variable which can be in the format "mm:ss" or "hh:mm:ss". I would
like to extract the total number of seconds from this.
Ie "01:30" would be 90 seconds.
Thanks in advance !
|
by: nriesch |
last post by:
In the documentation, the "Second" property of class
DateTime is a value between 0 and 59.
In UTC time, approximately every year of so, a leap
second is added at 00:00:00 UTC, so as to account...
|
by: Nikeman |
last post by:
good day,
I simply would like to know as to how I can parse seconds to convert them
into equivalent DateTime representation. To be more persice,
I have a DirectShow app written in VB.NET, with a...
|
by: Dr John Stockton |
last post by:
I'm starting a new thread, for clarity.
I'm assuming that it's ECMA-262 3rd Edn (1999) that we should be using
for Web pages; that 4th Edn (what's its present status? is it
available?) is too...
|
by: charlie strauss |
last post by:
Below is a simple program that will cause python to intermittently
stop executing for a few seconds. it's 100% reproducible on my machine.
I'd be tempted to say this is a nasty garbage...
|
by: edfialk |
last post by:
Hi, does anyone happen to know of a script that would return the
number of seconds in a month if I give it a month and a year?
My python is a little weak, but if anyone could offer some...
|
by: David T. Ashley |
last post by:
I have Red Hat Enterprise Linux 4.
I was just reading up about UTC and leap seconds.
Is it true on my system that the Unix time may skip up or down by one second
at midnight when there is a...
|
by: =?Utf-8?B?U2hlbGRvbg==?= |
last post by:
Hello -
I have about ten integer values that each need to be converted to days,
hours, minutes and seconds. I can't seem to find a formula for same that
works. These integer values come from a...
|
by: =?Utf-8?B?U2hlbGRvbg==?= |
last post by:
Hello -
I have various times formatted like 00:00:00, so for example, 01:32:05 would
be one thirty-two with five milliseconds.
I need to convert this into seconds (an integer).
First of...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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
|
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...
|
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: 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,...
|
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...
| |