Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7311

Re: Verifying time in php

From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: Verifying time in php
Date 2012-10-14 15:03 +0200
Message-ID <advrhmFroasU1@mid.individual.net> (permalink)
References <slrnk7l2e1.3f9.houghi@penne.houghi> <slrnk7l52o.3f9.houghi@penne.houghi>

Show all headers | View raw


On 14/10/12 12:30, houghi wrote:
> houghi wrote:
>> I have a form that has the following entry fields:
>> hours
>> minutes
>> seconds
>
> The code can be seen here : http://houghi.org/gopro.php?code
>
> $realtime=$_POST['hours']*3600+$_POST['minutes']*60+$_POST['seconds'];
>
> What I want to know if the $realtime is something I could get an error
> message form.

You would in most cases have a value of some sort, but you can't always 
relay on that it will for ever be like that (we know PHP makes some big 
changes from time to time) and what happens further down if you have 
negative values or huge values.

Validate what you get and make a sanity check on what you got before you 
calculate the realtime value.


> I just want to figure out how I can check if Hours, Minutes and Seconds
> input is valid.

There are quite many is_* functions, among those you have 
is_numeric()[1] and another one is isset()[2] which gives you true or false.


[1]: http://www.php.net/manual/en/function.is-numeric.php
[2]: http://www.php.net/manual/en/function.isset.php

-- 

  //Aho

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 11:45 +0200
  Re: Verifying time in php Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-14 10:25 +0000
    Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 13:50 +0200
      Re: Verifying time in php Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-14 21:12 +0000
  Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 12:30 +0200
    Re: Verifying time in php "J.O. Aho" <user@example.net> - 2012-10-14 15:03 +0200
      Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 17:16 +0200
        Re: Verifying time in php Michael Fesser <netizen@gmx.de> - 2012-10-14 17:50 +0200
          Re: Verifying time in php "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-10-14 18:22 +0200
          Re: Verifying time in php "Peter H. Coffin" <hellsop@ninehells.com> - 2012-10-14 11:41 -0500
            Re: Verifying time in php Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-10-14 11:06 -0600
              Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 19:41 +0200
            Re: Verifying time in php Michael Fesser <netizen@gmx.de> - 2012-10-14 21:03 +0200
              Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 22:39 +0200
        Re: Verifying time in php Christoph Becker <cmbecker69@gmx.de> - 2012-10-14 17:52 +0200
        Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 19:20 +0200
          Re: Verifying time in php "J.O. Aho" <user@example.net> - 2012-10-14 20:41 +0200
          Re: Verifying time in php Christoph Becker <cmbecker69@gmx.de> - 2012-10-14 20:49 +0200
            Re: Verifying time in php houghi <houghi@houghi.org.invalid> - 2012-10-14 22:32 +0200
  Re: Verifying time in php Richard Damon <news.x.richarddamon@xoxy.net> - 2012-10-14 11:44 -0400
  Re: Verifying time in php Luuk <luuk@invalid.lan> - 2012-10-14 21:28 +0200

csiph-web