World Time Clock Link Demo

This is a demo of the function below intended to convert a unix time code to a World Time Clock link, intended for sites where a time is known (e.g. from a database) and a link needs to be generated. I just put this into action for the MIDEA events items in Wordpress

In this example the time zone of the source is set to be US/Pacific, but is easily edited in the code or can be passed as a paramater (I dont feel like making a fancy menu for this demo, sue me.) In the demo, I allow you to enter a date (and time if you like) in a string format, and then use strtotime() on that value to pass to my function, which wants unix time.

Enter a Date (Month, date year, and optionally Hour:minutes am/pm)

The Code

function get_worldtimeclock ($ts, $tz=224) {
	// generates a URL for a world time clock link for a given timestamp $ts
	// default timezine (for this site) is 197 or Phoenix, hey thats my time zone

	
	$when = getdate($ts);
	
	return 'http://www.timeanddate.com/worldclock/fixedtime.html?month=' 
	  . $when['mon']  . '&day=' . $when['mday']  
	  . '&year=' . $when['year']  . '&hour=' 
	  . $when['hours']  . '&min=' . $when['minutes']  
	  . '&sec=0&p1=' . $tz;

}