Jump to content


Photo

Complex time problem.. Gurus can help


  • Please log in to reply
3 replies to this topic

#1 karthikeyan_coder

karthikeyan_coder
  • Members
  • PipPipPip
  • Advanced Member
  • 201 posts

Posted 16 October 2006 - 05:44 PM

here is the two functions for showing time in the format "3:57 pm"

function convert_timestamp($timestamp, $timezoneOffset=0) {
		$replacements = array(  '-' => '', 
								' ' => '', 
								':' => ''); 
		$timestamp = strtr($timestamp, $replacements); 
		
		return $timestamp?mktime(
			substr($timestamp,8,2),
			substr($timestamp,10,2) - $timezoneOffset + $GLOBALS['fc_config']['timeOffset'],
			substr($timestamp,12,2),
			substr($timestamp,4,2),
			substr($timestamp,6,2),
			substr($timestamp,0,4)
		):0;
	}

	function format_Timestamp($timestamp, $tzoffset) {
		return gmdate($GLOBALS['fc_config']['timeStampFormat'], convert_timestamp($timestamp, $tzoffset));
	}

i need these functions to show US time... how can we change these functions to show US time?

Thank you.

www.karthi.us

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 October 2006 - 05:57 PM

Why can't you use the date() function to format the time string?

Ken

#3 karthikeyan_coder

karthikeyan_coder
  • Members
  • PipPipPip
  • Advanced Member
  • 201 posts

Posted 16 October 2006 - 06:01 PM

ohh... ok... how can i make gmt conversions from the actual server time?
www.karthi.us

#4 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 16 October 2006 - 06:13 PM


<?php

echo date("h:i a"); // format 3:57 pm

echo date("h:i a",strtotime('now + 2 hours')); // + 2 hours = 5:57 pm

echo date("h:i a",strtotime('now - 1 hours')); // - 1 hour = 2:57 pm

?>






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users