Welcome Guest [Log In] [Register]

Notice!



We moved!

Please visit us at our new location which can be accesed through http://forum.legendarena.com/ or via legendarena.mypunbb.com
Add Reply
PHP Time Zone Convertor
Topic Started: Jun 5 2009, 10:11 PM (121 Views)
ReidE96
Member Avatar
Mr. Romance
[ * ]
Made this for another site where I'm the webmaster, after extensive googling for something like this turned up nothing. The code is Copyright Euan Reid, 2009 (Euan Reid is, as some folk here know, my real name). Free to use and distribute, only limitation is that you share all the changes you make here for others. Oh, and that you can't sell it. You don't need to credit me.

Quote:
 
<!-- TZC -->
<form action="<?php echo(htmlentities($_SERVER['PHP_SELF'])) ?>" method="POST">

<!-- PHP function -->
<?php
if ($_POST['time'] != NULL)
{
$time_input = htmlentities($_POST['time']);
$from = htmlentities($_POST['from']);
$to = htmlentities($_POST['to']);
putenv("TZ=".$from);
$time = strtotime($time_input);
putenv("TZ=".$to);
echo '<script type="text/javascript">window.alert("'.date("Y-m-d H:i:s", $time).'")</script>';
}
?>

<!-- Form -->
Convert From:
<select name="from">
<option value="Pacific/Apia">SST</option>
<option value="Pacific/Honolulu">HST</option>
<option value="America/Anchorage">AKST</option>
<option value="America/Los_Angeles" selected>PST</option>
<option value="America/Denver">MST</option>
<option value="America/Chicago">CST</option>
<option value="America/New_York">EST</option>
<option value="America/Halifax">AST</option>
<option value="America/Argentina/Catamarca">GMT-3</option>
<option value="Atlantic/South_Georgia">GMT-2</option>
<option value="Atlantic/Cape_Verde">GMT-1</option>
<option value="Europe/London">GMT</option>
<option value="Europe/Paris">GMT+1</option>
<option value="Europe/Athens">GMT+2</option>
<option value="Europe/Moscow">GMT+3</option>
<option value="Asia/Tbilisi">GMT+4</option>
<option value="Asia/Dushanbe">GMT+5</option>
<option value="Asia/Almaty">GMT+6</option>
<option value="Asia/Phnom_Penh">GMT+7</option>
<option value="Asia/Shanghai">GMT+8</option>
<option value="Asia/Tokyo">GMT+9</option>
<option value="Pacific/Port_Moresby">GMT+10</option>
<option value="Pacific/Noumea">GMT+11</option>
<option value="Pacific/Majuro">GMT+/-12</option>
</select>
Convert To:
<select name="to">
<option value="Pacific/Apia">SST</option>
<option value="Pacific/Honolulu">HST</option>
<option value="America/Anchorage">AKST</option>
<option value="America/Los_Angeles" selected>PST</option>
<option value="America/Denver">MST</option>
<option value="America/Chicago">CST</option>
<option value="America/New_York">EST</option>
<option value="America/Halifax">AST</option>
<option value="America/Argentina/Catamarca">GMT-3</option>
<option value="Atlantic/South_Georgia">GMT-2</option>
<option value="Atlantic/Cape_Verde">GMT-1</option>
<option value="Europe/London">GMT</option>
<option value="Europe/Paris">GMT+1</option>
<option value="Europe/Athens">GMT+2</option>
<option value="Europe/Moscow">GMT+3</option>
<option value="Asia/Tbilisi">GMT+4</option>
<option value="Asia/Dushanbe">GMT+5</option>
<option value="Asia/Almaty">GMT+6</option>
<option value="Asia/Phnom_Penh">GMT+7</option>
<option value="Asia/Shanghai">GMT+8</option>
<option value="Asia/Tokyo">GMT+9</option>
<option value="Pacific/Port_Moresby">GMT+10</option>
<option value="Pacific/Noumea">GMT+11</option>
<option value="Pacific/Majuro">GMT+/-12</option>
</select>
Time: <input type="text" name="time" value="<?php echo date("Y-m-d H:i:s") ?>"/>
<input type="submit" value="Convert!" />
</form>


If any of you DO google it and turn up a result on MMOwned.com, note that post is also by ReidE96. That's another forum I frequent, and I posted it there too.
Posted Image
Rewards1
Posted Image
Offline Profile Quote Post Goto Top
 
Ken
Member Avatar
Charioteer
[ * ]
I call dibs therefore your copyright doesn't work anymore therefore I bid to you my dear friend; Fail.
Posted Image
Offline Profile Quote Post Goto Top
 
ReidE96
Member Avatar
Mr. Romance
[ * ]
Shame it's copyright. Anyways, it's not like I'm selling it or anything, I just thought someone else may, at some point, want something like it, and I know how much effort it took. Until I learned about putenv.
Posted Image
Rewards1
Posted Image
Offline Profile Quote Post Goto Top
 
Bandos
Member Avatar
Undertaker
[ * ]
do i understand any of that lol?
Oops "my jawbreaker slipped into your nutsack my "bad" LOL"
Offline Profile Quote Post Goto Top
 
K-B
Member Avatar
Farrier
[ * ]
what language did you code this in?
Posted Image
Offline Profile Quote Post Goto Top
 
Brithor
Lil' Chico
[ * ]
K-B
Jul 6 2009, 11:17 AM
what language did you code this in?
Read the thread title much?

PHP
Posted Image
Offline Profile Quote Post Goto Top
 
ReidE96
Member Avatar
Mr. Romance
[ * ]
Facepalm at kb.
Posted Image
Rewards1
Posted Image
Offline Profile Quote Post Goto Top
 
ovesh
Member Avatar
king of the world
[ * ]
nice I like it.
Works well only why did you GMT everywhere except the US?
Edited by ovesh, Jul 8 2009, 07:48 PM.
Posted Image

I asked God for a bike, but I know God doesn't work that way. So I stole a bike and asked for forgiveness.

We live in a society where pizza gets to your house before the police.


Light travels faster than sound. This is why some people appear bright until you hear them speak.

Having sex is like playing bridge. If you don't have a good partner, you'd better have a good hand.
Offline Profile Quote Post Goto Top
 
ReidE96
Member Avatar
Mr. Romance
[ * ]
Cause I don't know the time zone names aside from the US ones and GMT :P And I only know the US ones cause the website is in the US.

Edit: The server's timezone is PST, hence why it's the default. You can change it by changing which item in the dropdown has the "selected" part in it.
Edited by ReidE96, Jul 9 2009, 12:46 PM.
Posted Image
Rewards1
Posted Image
Offline Profile Quote Post Goto Top
 
ovesh
Member Avatar
king of the world
[ * ]
you have any other projects?
Posted Image

I asked God for a bike, but I know God doesn't work that way. So I stole a bike and asked for forgiveness.

We live in a society where pizza gets to your house before the police.


Light travels faster than sound. This is why some people appear bright until you hear them speak.

Having sex is like playing bridge. If you don't have a good partner, you'd better have a good hand.
Offline Profile Quote Post Goto Top
 
ReidE96
Member Avatar
Mr. Romance
[ * ]
Uh.... one to hide bits of text a la spoiler tags using Javascript? Why, are you making a website?
Posted Image
Rewards1
Posted Image
Offline Profile Quote Post Goto Top
 
ovesh
Member Avatar
king of the world
[ * ]
had one but it is down now I will spend time making stuff in the summer which for me hasn't started yet.

Why not make something big? or do you not have the time for it?
Posted Image

I asked God for a bike, but I know God doesn't work that way. So I stole a bike and asked for forgiveness.

We live in a society where pizza gets to your house before the police.


Light travels faster than sound. This is why some people appear bright until you hear them speak.

Having sex is like playing bridge. If you don't have a good partner, you'd better have a good hand.
Offline Profile Quote Post Goto Top
 
ReidE96
Member Avatar
Mr. Romance
[ * ]
Too many other things to spend time on :)
Posted Image
Rewards1
Posted Image
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Graphics and ICT · Next Topic »
Add Reply

//