HI. Can someone please tell me why this simple operation doesnt work?

$time1_offset * -1;

What are you doing with the result?

Once I get the result, It will be multiplied again and then entered into a new variable that will be added to a new variable that will be displayed. The second operation works

$time_o = ($time1_offset * 3600);

and the 3rd one works

$time + $time_o

but the 1st doesnt.

Are you taking the result variables out of the code you're showing on purpose? I don't know what the previous code for $time1_offset is, but I suppose you could try the following:

$result = ((int) $time1_offset) * -1

Nope, heres pretty much the whole thing:

$usertimezone = $user->member['timezone'];
				$time1_offset = $timezonearray[$usertimezone]; 
				if($usertimezone == "GMT-6" || $usertimezone == "GMT-7" || $usertimezone == "GMT-8" || $usertimezone == "GMT-9" || $usertimezone == "GMT-10" || $usertimezone == "GMT-11") {
					$time1_offset * -1;
					}

$time_o = ($time1_offset * 3600);
$time = date("H",time() + $time_o);
echo $time;

$usertimezone gets the users timezone. Using myself for an example, $usertimezone will equal GMT-8. There is an .inc file with the $timezonearray looking like this:

$timezonearray["GMT-11"] = 6;
$timezonearray["GMT-10"] = 5;
$timezonearray["GMT-9"]  = 4;
$timezonearray["GMT-8"]  = 3;  
$timezonearray["GMT-7"]  = 2;

So $time1_offset should equal 3 for me, which it does. The rest doesnt work. The second and third operations work, but the 1st doesnt.

Like I said, you're not storing the result. You're just doing $time1_offset * -1; . There's no assignment operator (=) in the statement. The operation is working, you're just not storing the result anywhere. I think you may have meant to do this instead:

$time1_offset *= -1
commented: Informative post, helped me with my issue. +1

Ah I see. Thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.