Saturday 2 April 2011

Php Code tip. Displaying your server location by exploding time

I was playing with some php code earlier today and wondering if i could write a little piece of lazy code to write the local location of my server instead of having to type the city/town and country each time. And then i remembered the timezone gave almost exactly what i want.

You know, this bit of code:
<?php echo date('e'); ?>


except it is backwards and can have up to three fields all with a pedantic / in the middle, so i thought ok, how about i strip out the slash and reverse the order. Close enough.

<?php
$zones = explode("/", date('e'));
echo "$zones[2] ";
echo "$zones[1] ";
echo "$zones[0] ";
?>

and then i thought, oh yeah, that works. But i can't be bothered with it anymore. Maybe some else is looking for it. And there it is

No comments:

Post a Comment

Important Note:

Anyone is free to post links here but only if a back link to this site (or www.websiteadministrator.com.au) is added from your blog or website.