how to obtain same date result on diferent servers

<?php

//                            viper-7            phpfiddle
fdate(1346976000);       // Fri 2012-09-07     Thu 2012-09-06
fdate(1348704000);       // Thu 2012-09-27     Wed 2012-09-26
fdate(time());           // see yourself

function fDate($what){echo date('D Y-m-d',$what).'<br>';}

?>

test links http://codepad.viper-7.com/d4tUES http://www.phpfiddle.org/main/code/zdx-u10

What do I need to set up in order to have the same results on any server? Thanks

I am sure is a matter of time zone, but I do not know how to be aware of this.

Answers


Set the default timezone

Set it to UTC or GMT and you can use it as a basis for all your servers

date_default_timezone_set('UTC'); 

fdate(time());  // will return the UTC time

use gmdate to return gmt time

function fDate($what){echo gmdate('D Y-m-d',$what).'<br>';}

see if you still have issues.


Include date_default_timezone_set at the beginning of your script based on your desired timezone.

<?php
date_default_timezone_set('America/Los_Angeles');
?>

List of Supported Timezones


Need Your Help

JDBC error after application runs for a while

java jdbc jruby

MySQL Connector/J (version 5.1.6) gets me the following error after a few minutes of opening and closing connections every second):

Checkbox is always coming as unchecked

jquery asp.net-mvc kendo-ui kendo-grid telerik-mvc

I have following Kendo Grid ans associated jQuery. On a button click, I need to know whether checkbox is checked. But at present it is showing 'false' always. How can we correct it?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.