Jump to content

aximbigfan

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Posts posted by aximbigfan

  1. So I have these variables...

                    $curtz // Timezone I want to convert to (example "-0600")

                    $date['TZ'] // Timezone of the time I want to convert to $curtz (example "-0800")

    $date['D'] // Day (example "8")

    $date['M'] // Month (example "1")

    $date['Y'] // Year (example "2009")

     

    $date['H'] // Hour (example "23")

    $date['Min'] // Minute (example "59")

    $date['S']  //Second (example "59")

     

    And I have this horrible code...

    		if ($curtz!=$date['TZ'])
    	{
    		$direction = substr($date['TZ'], 0, 1);
    		$hours     = substr($date['TZ'], 1, 2);
    
    		if ($direction=='+')
    		{
    			$date['H'] = $date['H'] - $hours;
    			if ($date['H']<0)
    			{
    				$date['H'] = $date['H'] + 23;
    				$date['D']--;
    			}
    		}
    		else
    		{
    			$date['H'] = $date['H'] + $hours;
    			if ($date['H']>23)
    			{
    				$date['H'] = $date['H'] - 23;
    				$date['D']++;
    			}
    		}
    
    		$direction = substr($curtz, 0, 1);
    		$hours     = substr($curtz, 1, 2);
    
    		if ($direction=='+')
    		{
    			$date['H'] = $date['H'] + $hours;
    			if ($date['H']>23)
    			{
    				$date['H'] = $date['H'] - 23;
    				$date['D']++;
    			}
    		}
    		else
    		{
    			$date['H'] = $date['H'] - $hours;
    			if ($date['H']<0)
    			{
    				$date['H'] = $date['H'] + 23;
    				$date['D']--;
    			}
    		}
    
    		if ($date['D']>$this->months[$date['M']][1])
    		{
    			$date['M']++;
    			if ($date['M']>12)
    			{
    				$date['M'] = 1;
    				$date['Y']++;
    			}
    			$date['D'] = 1;
    		}
    		elseif ($date['D']<=0)
    		{
    			$date['M']--;
    			if ($date['M']<=0)
    			{
    				$date['M'] = 12;
    				$date['Y']--;
    			}
    			$date['D'] = $this->months[$date['M']][1];
    		}
    	}

     

    Yes, I know, the above code is disgusting, and probably doesn't work right.

     

    Can anyone give me some pointers on how to fix this, or a better way of converting times between timezones?

     

    Thanks!

    Chris

  2. I made my own database server............ Out of PHP in CLI.

    I coded a system to change my desktop wallpaper with one in a MySQL databse, in such a way that all wallpapers are selected an equal number of times.

    I have 4 servers in my room. 3 embedded ARM9/MIPS and one X86.

     

    I rated myself a 10.

     

    Chris

  3. Hey James, get a clue!

     

    Your probably one of those people who goes around self diagnosing yourself with "ass-burgars". I seriously doubt you have it, instead, I think you have a bad case of mental retardation.

     

    Go read a tutorial, get somewhat good, then ask for help. Quit trying to get spoon fed. All your code samples are awful. Learn to make useful comments (not "// some code"), and keep your stuff consistent.

     

  4. @Corbin, I would have to agree, at least from a logical standpoint.

     

    Anyone wanna give this a shot on an older version of PHP (blatent rip off of Corbin's)

    function RetArr()
    {
    echo "Function Run";
    return array (1, 2, 3);
    }
    
    foreach (RetArr() as $val)
    {
    echo $val;
    }
    

     

    On PHP 5.2.4 I get "Function Run123" which is expected.

     

    Chris

  5. Which one of these method is the better way? (IE, more efficient)

     

    // Method one
    $str = '1|2|3|4|5|6';
    
    foreach (explode('|', $str) as $key=>$val)
    {
    //Do something here
    }
    
    
    // Method 2
    $str = '1|2|3|4|5|6';
    $arr = explode('|', $str);
    
    foreach ($arr as $key=>$val)
    {
    //Do something here
    }
    

     

    Normally, I just use method 1. Will PHP run that function every alliteration, or will it run it once, and cache the array? I would think it would just cache the array...

     

    Thanks,

    Chris

     

     

  6. Australia dosnt have too many bad crimes.......cause we dont have guns!

     

    You don't need a gun to commit a 'bad crime', which is a relative term anyway.

     

    Ppl who suffer from rage are extremely dangerous. Thats why personal guns need to be banned.....i mean buying a gun at wallmart WTF!!

     

    How many ppl do you know who flip out over minor shit??

     

    http://au.youtube.com/watch?v=7Sq-HYGfnIo

     

    Imagine if this was a gun and not an axe...

     

    You're logic doesn't make sense in the least.

     

    When you outlaw guns, only outlaws have them.

     

    Crime would run rampant since criminals would get guns, and people would be defenseless.

     

    Chris

  7. Personally, if someone colors an entire post then I'll edit it. Had I not been able to do that then I wouldn't read the post at all.

     

    Some colors are ok, like blue, since it is often used in emails. But like red, or brown, yeah, no.

     

    I do agree with the point about this being an English board, and that if people are going to post on it, they need to least know a degree of English.

     

     

    Chris

  8. To be honest, I never used the serialize and unserialize functions 'til now. I've ran a simple test and, yes, this would be my chosen way :)thank you very much, aximbigfan.

    see you guys around!

     

    :) [/]

     

    Sure! This is the best way I have found. It also allows me to mod a bunch of keys at once, plus, 3d arrays!

     

    Chris

  9. Could some mod maybe make a sticky out of a thread asking people to PLEASE USE PROPER ENGLISH? and while were at it, a proper guide to posting?

     

    I'm constantly seeing threads where people vomit all over the English language, and when I see these, I immediately click back.

     

    I don't know if there is a formatting guide out there now, but here is one that I made up

     

    • Don't post in all CAPS
    • Don't give people a time line to help you. Everyone on this forum is a volunteer. If you want things done ultra quickly, hire a programmer
    • Don't abuse similes. One or two is fine, but no long strings of them
    • Do SEARCH before you post
    • Do spell check before posting
    • Don't bold/italicize/underline your entire post
    • Do post relevant code!
    • Don't abuse font sizes/color

     

    Thanks,

    Chris

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.