<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Snippets &#8211; Blackbams Blog</title>
	<atom:link href="https://blog.blackbam.at/tag/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.blackbam.at</link>
	<description>development - digital arts - internet</description>
	<lastBuildDate>Tue, 16 Oct 2012 22:55:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Calculate Local Timestamp (with Summertime) from UTC-Timestamp in PHP</title>
		<link>https://blog.blackbam.at/2012/10/17/calculate-european-summertime-from-utc-timestamp-in-php/</link>
					<comments>https://blog.blackbam.at/2012/10/17/calculate-european-summertime-from-utc-timestamp-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Blackbam]]></dc:creator>
		<pubDate>Tue, 16 Oct 2012 22:53:15 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Snippets]]></category>
		<guid isPermaLink="false">https://blog.blackbam.at/?p=2000</guid>

					<description><![CDATA[As it was a bit tricky to find out how this works, I want to share this script. This is how you can convert a UTC timestamp without offset and summertime into a converted timestamp using PHP. This is especially useful when extending a Calendar Plugin for example, which saves its dates in UTC-timestamps while [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>As it was a bit tricky to find out how this works, I want to share this script. This is how you can convert a UTC timestamp without offset and summertime into a converted timestamp using PHP. This is especially useful when extending a Calendar Plugin for example, which saves its dates in UTC-timestamps while local time is needed.</p>
<pre lang="php">
/** Calculate middle european summertime */
function utc_to_local_time($timestamp,$offset=0,$summertime=true) { 
	 $year = strftime("%Y", $timestamp); 
	$timestamp += (3600*intval($offset)); // add local offset
	
	// Calculate beginning and end of Summertime
	$initTime = mktime(2,0,0,3,31-date('w', mktime(2,0,0,3,31,$year)),$year); 
	$endTime = mktime(2,0,0,10,31-date('w', mktime(2,0,0,10,31,$year)),$year); 

    // Check if summertime, return adequatly
    if (($timestamp > $initTime && $timestamp < $endTime) &#038;&#038; $summertime) { 
        return ($timestamp + 3600); 
    } else { 
        return ($timestamp); 
    } 
}

// example: Austria time
echo date("d.m.Y, H:i",utc_to_local_time($utc_time,1);
</pre>
<p><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fblog.blackbam.at%2F2012%2F10%2F17%2Fcalculate-european-summertime-from-utc-timestamp-in-php%2F&#038;title=Calculate%20Local%20Timestamp%20%28with%20Summertime%29%20from%20UTC-Timestamp%20in%20PHP" data-a2a-url="https://blog.blackbam.at/2012/10/17/calculate-european-summertime-from-utc-timestamp-in-php/" data-a2a-title="Calculate Local Timestamp (with Summertime) from UTC-Timestamp in PHP"><img src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.blackbam.at/2012/10/17/calculate-european-summertime-from-utc-timestamp-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
