Index: formatting.php
===================================================================
--- formatting.php	(revision 28636)
+++ formatting.php	(working copy)
@@ -2292,6 +2292,84 @@
 }
 
 /**
+ * Returns a formatted date in the local timezone. This is a drop-in
+ * replacement for `date()`, except that the returned string will be formatted
+ * for the local timezone.
+ *
+ * If there is a timezone_string available, the date is assumed to be in that
+ * timezone, otherwise it simply subtracts the value of the 'gmt_offset'
+ * option.
+ *
+ * @uses get_option() to retrieve the value of 'gmt_offset'.
+ * @param string $format The format of the outputted date string.
+ * @param string $timestamp Optional. If absent, defaults to `time()`.
+ * @return string GMT version of the date provided.
+ */
+function wp_date( $format, $timestamp = false ) {
+	$tzstring = wp_get_timezone_string();
+
+	// Set to local timezone temporarily
+	date_default_timezone_set( $tzstring );
+	if ( ! $timestamp ) {
+		$timestamp = time();
+	}
+	$date = date( $format, $timestamp );
+	date_default_timezone_set( 'UTC' );
+
+	return $date;
+}
+
+/**
+ * Converts a locally-formatted date to a unix timestamp. This is a drop-in
+ * replacement for `strtotime()`, except that where strtotime assumes GMT, this
+ * assumes local time (as described below). If a timezone is specified, this
+ * function defers to strtotime().
+ *
+ * If there is a timezone_string available, the date is assumed to be in that
+ * timezone, otherwise it simply subtracts the value of the 'gmt_offset'
+ * option.
+ *
+ * @see strtotime()
+ * @uses get_option() to retrieve the value of 'gmt_offset'.
+ * @param string $string A date/time string. See `strtotime` for valid formats.
+ * @return int UNIX timestamp.
+ */
+function wp_strtotime( $string ) {
+	$tzstring = wp_get_timezone_string();
+
+	// Set to local timezone temporarily
+	date_default_timezone_set( $tzstring );
+	$timestamp = strtotime( $string );
+	date_default_timezone_set( 'UTC' );
+
+	return $timestamp;
+}
+
+/**
+ * Get the timezone string for the current site.
+ *
+ * @see http://us3.php.net/manual/en/timezones.php
+ *
+ * @return string A valid timezone string, e.g. "America/New_York".
+ */
+function wp_get_timezone_string() {
+	$tzstring = get_option( 'timezone_string' );
+
+	if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
+		$current_offset = get_option( 'gmt_offset' );
+		if ( 0 == $current_offset ) {
+			$tzstring = 'UTC+0';
+		} elseif ( $current_offset < 0 ) {
+			$tzstring = 'UTC' . $current_offset;
+		} else {
+			$tzstring = 'UTC+' . $current_offset;
+		}
+	}
+
+	return $tzstring;
+}
+
+/**
  * Adds a element attributes to open links in new windows.
  *
  * Comment text in popup windows should be filtered through this. Right now it's
