





<?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>we Archives - Netgen IT Solutions</title>
	<atom:link href="https://netgen.in/tag/we/feed/" rel="self" type="application/rss+xml" />
	<link>https://netgen.in/tag/we/</link>
	<description>Your Partner in Everything IT</description>
	<lastBuildDate>Thu, 27 Jun 2024 05:44:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://netgen.in/wp-content/uploads/2024/03/favicon-16x16-1.png</url>
	<title>we Archives - Netgen IT Solutions</title>
	<link>https://netgen.in/tag/we/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Convert time from one timezone to another</title>
		<link>https://netgen.in/convert-time-from-one-timezone-to-another/</link>
		
		<dc:creator><![CDATA[Netgen IT Solutions]]></dc:creator>
		<pubDate>Sat, 30 Aug 2014 05:38:27 +0000</pubDate>
				<category><![CDATA[Website Design]]></category>
		<category><![CDATA[we]]></category>
		<guid isPermaLink="false">https://beta.netgen.work/?p=624</guid>

					<description><![CDATA[<p>Sometimes we need to convert time from one timezone to another. so best thing is to save the time in UTC/GMT and then convert it back to required timezone by php datetime functions. E.g If we have to send email to users according to their selected time , then first we will save the user [&#8230;]</p>
<p>The post <a href="https://netgen.in/convert-time-from-one-timezone-to-another/">Convert time from one timezone to another</a> appeared first on <a href="https://netgen.in">Netgen IT Solutions</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes we need to convert time from one timezone to another. so best thing is to save the time in UTC/GMT and then convert it back to required timezone by php datetime functions.<br />
E.g If we have to send email to users according to their selected time , then first we will save the user time to UTC/GMT and his timezone in the database. and when we are sending emails by running cron jobs or whatever, we will convert the time from user timezone to server timezone and check if the time is same.</p>
<p>I have found this simple function with which we can simply convert time from different timezones.</p>
<pre class="brush: php; gutter: true; first-line: 1; highlight: []; html-script: false">function converToTz($time="",$toTz='',$fromTz='')
	{	
		// timezone by php friendly values
		$date = new DateTime($time, new DateTimeZone($fromTz));
		$date-&gt;setTimezone(new DateTimeZone($toTz));
		$time= $date-&gt;format('Y-m-d H:i:s');
		return $time;
	}</pre>
<p>we will use this function first to convert user time and then checking the time for users timezone. Check for supported timezones by php datetime function Supported <a href="http://in2.php.net/manual/en/timezones.php">Timezones in PHP</a><br />
E.g</p>
<pre class="brush: php; gutter: true; first-line: 1; highlight: []; html-script: false">$time="2012-01-23 10:30:00"; // User selected time to get email.
$timezone="Asia/Kolkata";     
$save_time2database=convertToTz($time,'UTC',date('e')); // Convert time from server time to UTC
mysql_query('insert into users set time="'.$save_time2database.'", timezone="'.$timezone.'"'); // and save this time to database


// Check time for sending email for user.
$userTime="2012-01-23 05:00:00";  // Data saved for user in UTC format
$userTimezone="Asia/Kolkata";      // User timezone
$userConvertedTime=convertToTz($userTime,$userTimezone,'UTC');
if(date('Y-m-d H:i:s')==$userConvertedTime)
{
mail('admin@digital6technologies.com','Time to Launch');
}</pre>
<p>The post <a href="https://netgen.in/convert-time-from-one-timezone-to-another/">Convert time from one timezone to another</a> appeared first on <a href="https://netgen.in">Netgen IT Solutions</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
