Skip to content

Instantly share code, notes, and snippets.

@jamesmoss
Created April 21, 2011 08:43
Show Gist options
  • Save jamesmoss/933995 to your computer and use it in GitHub Desktop.
Save jamesmoss/933995 to your computer and use it in GitHub Desktop.
<?php
// 0:00 1/1/2011 UTC
$some_time = 1293840000;
$some_timezone = 'Europe/Moscow';
date_default_timezone_set($some_timezone);
require('Twig/lib/Twig/Autoloader.php');
Twig_Autoloader::register();
$loader = new Twig_Loader_String();
$twig = new Twig_Environment($loader);
$template = $twig->loadTemplate("TWIG: The time in {{ some_timezone }} at 0:00 1/1/2011 UTC was: {{ some_time|date('r') }}");
header('Content-type: text/plain');
var_dump($template->render(array('some_time' => $some_time, 'some_timezone' => $some_timezone)));
var_dump('NATIVE: The time in '.$some_timezone.' at 0:00 1/1/2011 UTC was: '.date('r', $some_time));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment