Forum Moderators: coopster

Message Too Old, No Replies

Timestamp? using PHP to change a date on a page

php will change the date on the page as of a specific day

         

mikejson

8:01 pm on Aug 7, 2003 (gmt 0)

10+ Year Member



Basically I want to use php and I think it's called "timestamp" but I"m not sure. I want to use it to get the YMD date and if it's September 1st, I want to update the date to be of that year within the web page. This will also be used as part of a form as well. I also want to change a few other things on the page if this date is some arbitrary date, but I can do that if I know how to do the first part.

Thanks for your help guys(I'm googling that timestamp thing right now too)

jatar_k

8:27 pm on Aug 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



how about this
[ca.php.net...]

mikejson

2:03 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



Ok great, I found how to get it, now I think I'm messing up on something else.

I'm just testing this out but basically as of Sept first, I want my form to have the year+1(eg, on Sept. 1st, 2003 i should get 2004).

This is my code for testing.
//begin code snip
<?php
$monthtemp = date("n");
$yeartemp = date("Y");
$datetemp = date("j");
if( monthtemp >= 8 )
$year = $yeartemp + 1;
else
$year = $yeartemp;
echo ($year);
?>

//end code snip

Now I'm new to php coding, but I assume it uses alot of standard coding like ">=" is greater than or equal to... and so on.

So if it's the 8th month(this is for testing cause the server time is out of my hands to change) then as of August it should give me 2004, which it's not, it's still giving me 2003.

Anyone?

thanks for the push in the right direction on the last reply

mikejson

2:06 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



hmm, I just thought of something. Does PHP treat everything as strings? If so, maybe comparing the string $monthtemp to a int like 8 would never evaluate to true.... Could it be that I need to use a string equater? like in java?

<string>.isequal( <comparing string> )

Something like that?

mikejson

2:43 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



Heh, ok, I got it. I casted everything to ints... date() returns a string, just for all you newbies like me out there :)