Forum Moderators: coopster

Message Too Old, No Replies

Timestamp troubles

Help!

         

freerange

8:22 pm on Jan 11, 2009 (gmt 0)

10+ Year Member



I'm using
//POST time
$time=time();

//Change the 0 if your server is located at a different GMT time
$time=($time+(0*3600));
$time=$time*1000;

which is producing
<input type="hidden" name="TimeStamp" value="1.231705102E+12">

How do I get it to produce an integer value instead?

PokeTech

11:03 pm on Jan 11, 2009 (gmt 0)

10+ Year Member



time() produces a timestamp obviously. Here's an example of a timestamp from around when this post was made: 1231714831.

With the date() function you can get the month, day, hour, min, sec.

example:

$time = time();
$date = date("l F d, Y, h:i A",$time);

that returns something like this: Sunday November 30, 2008, 03:50 PM

Is that what you mean?

janharders

11:21 pm on Jan 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it is producing an integer-value, just a very big one because you're converting it to milliseconds with

$time=$time*1000;

mcavic

11:31 pm on Jan 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In this particular example, instead of:
$time=$time*1000;

You can do:
$time .= "000"

That will turn it into a string for the purpose of passing it to the html code. But then when the form is posted, it'll probably be turned back into an integer, which will be more than 32 bits, and it might be an overflow depending on the language and what it's doing with it.

mcavic

1:23 am on Jan 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If it's your own PHP code that's handling the form submission, then you shouldn't need the 000 at all.

freerange

3:16 pm on Jan 13, 2009 (gmt 0)

10+ Year Member



Thanks for your help!

I'm now using
//POST time
$time=time();

//Change the 0 if your server is located at a different GMT time
$time=($time+(0*3600));
$time= $time."000";

and it works. <does happy dance>