Index: ParserFunctions.php
===================================================================
--- ParserFunctions.php	(revision 41831)
+++ ParserFunctions.php	(working copy)
@@ -396,14 +396,18 @@
 		if ( isset( $this->mTimeCache[$format][$date][$local] ) ) {
 			return $this->mTimeCache[$format][$date][$local];
 		}
-
-		if ( $date !== '' ) {
-			$unix = @strtotime( $date );
-		} else {
-			$unix = time();
+		
+		try {
+			if ( $date !== '' ) {
+				$dateObject = new DateTime( $date );
+			} else {
+				$dateObject = new DateTime(); #use current date and time
+			}
+		} catch (Exception $ex) {
+			$dateObject = false;
 		}
-
-		if ( $unix == -1 || $unix == false ) {
+		
+		if ( $dateObject === false ) {
 			wfLoadExtensionMessages( 'ParserFunctions' );
 			$result = '<strong class="error">' . wfMsgForContent( 'pfunc_time_error' ) . '</strong>';
 		} else {
@@ -413,20 +417,16 @@
 				return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_long' ) . '</strong>';
 			} else {
 				if ( $local ) {
-					# Use the time zone
-					if ( isset( $wgLocaltimezone ) ) {
-						$oldtz = getenv( 'TZ' );
-						putenv( 'TZ='.$wgLocaltimezone );
-					}
-					wfSuppressWarnings(); // E_STRICT system time bitching
-					$ts = date( 'YmdHis', $unix );
-					wfRestoreWarnings();
-					if ( isset( $wgLocaltimezone ) ) {
-						putenv( 'TZ='.$oldtz );
-					}
+					if ( isset( $wgLocaltimezone ) ) { #convert to MediaWiki local timezone if set
+						$dateObject->setTimeZone( new DateTimeZone( $wgLocaltimezone ) );
+					} #otherwise leave in PHP default
 				} else {
-					$ts = wfTimestamp( TS_MW, $unix );
+					#if local time was not requested, convert to UTC
+					$dateObject->setTimeZone( new DateTimeZone( 'UTC' ) );
 				}
+				
+				$ts = $dateObject->format( 'YmdHis' );
+				
 				if ( method_exists( $wgContLang, 'sprintfDate' ) ) {
 					$result = $wgContLang->sprintfDate( $format, $ts );
 				} else {
