<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
a) mktime() will return a (GMT based) unix timestamp, but assumes that
the params passed (namely, the 0 hour value) are local system time,
thus they will be converted to GMT first.&nbsp; the gmmktime() function
returns the same value format, but assumes that the params are already
in GMT, and will not do any further timezone shifting relative to local
system settings.&nbsp; You might want to play around with that function and
GMT params.&nbsp; NB: this is all at the PHP level, below the Drupal
application level.&nbsp; mktime() should work if your system's timezone
offset is set to what you expect.&nbsp; Is this hosted account somewhere or
a machine you control?<br>
roughly diagrammed:<br>
storage: mktime('local clock info') -&gt; filters through local system
timezone offset -&gt; GMT based unix timestamp<br>
storage: gmmktime('GMT clock info') -&gt; GMT based unix timestamp<br>
display: GMT based unix timestamp -&gt; format_date(...) -&gt; 'local
clock info'<br>
<br>
b) storing dates is a design decision that you have to really evaluate
from the start.&nbsp; int's and unix timestamps are a reasonable approach
though. check out <a href="http://drupal.org/node/262066">http://drupal.org/node/262066</a>
&amp; <a href="http://drupal.org/node/291799">http://drupal.org/node/291799</a>
for more info.&nbsp; The key with storing unix timestamps is to make sure
that everything is stored in the db in a uniform timezone offset
(ussually UTC).&nbsp; Understand how Drupal deals with timezone handling at
the application layer and don't try to "outsmart" it at the PHP layer.<br>
<br>
c) if all date's have been stored uniformly as unix timestamps:<br>
&nbsp; $month = format_date($node-&gt;data_assentament, 'custom', 'm');<br>
&nbsp; $day = format_date($node-&gt;data_assentament, 'custom', 'd');<br>
&nbsp; $year = format_date($node-&gt;data_assentament, 'custom', 'Y');<br>
<br>
The main idea here is that you have two layers of the application stack
(PHP and Drupal) both trying to be smart about timezone handling, and
each layer is undoing the other's efforts.&nbsp; You have to make one be
authoritative and the other passive from an application design
perspective.&nbsp; You will probably get the best results if you let Drupal
be the authoritative layer when it comes to timezones.<br>
<br>
Seth<br>
<br>
<br>
Llu&iacute;s wrote:
<blockquote
 cite="mid:45a29f450907170553o30ea6ebdn7417c9883a80c587@mail.gmail.com"
 type="cite">
  <pre wrap="">I have set timezone to UTC in admin/settings/date-time and no timezone for user.

So my problems are:
a) How do I have to store the date? is mktime(0,0,0,$month,$day,$year); correct?
b) If I want to use the date in views, how should I store it in
database? I use int(11) now
c) How can retrieve $month, $day, $year to make the form again?


On Fri, Jul 17, 2009 at 2:11 PM, Seth Freach<a class="moz-txt-link-rfc2396E" href="mailto:sfreach@gmail.com">&lt;sfreach@gmail.com&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Llu&iacute;s,

time() will return a value relative to the epoch, which is epicentered in
GMT.
date() takes that value and returns a local time based on it.&nbsp; IE, date()
knows about the computer's timezone and takes it into account.

Drupal's format_date() function uses gmdate() internally, which, unlike
date(), does not do local timezone offsetting. gmdate() returns the formated
date string in GMT.&nbsp; The reason format_date() does this is because it wants
to return a time that has meaning to the individual user's location, which
is not necessarily the computer's location, nor are all users always in the
same timezone.&nbsp; Drupal does the timezone offsetting itself to allow a system
default timezone and individual user configurable timezones too.

Double check your Drupal timezone settings at q=admin/settings/date-time and
possibly your user timezone settings at q=user/$uid/edit

Seth

Llu&iacute;s wrote:

Making some research my problem is with format date:

$node-&gt;data_assentament -&gt; 1247781600
date("d-m-Y H:i", $node-&gt;data_assentament) -&gt; 17-07-2009 00:00
format_date($node-&gt;data_assentament,'medium') -&gt; Dij, 07/16/2009 - 22:00

(I need the date in dd/mm/YYYY format)

Should I avoid format_date() or there is a better way to solve this?

On Thu, Jul 16, 2009 at 5:40 PM, Llu&iacute;s<a class="moz-txt-link-rfc2396E" href="mailto:enboig@gmail.com">&lt;enboig@gmail.com&gt;</a> wrote:


I have created a custom node type. I have a date field which I created
as int in order to use it in views, being able to sort it, format,
etc....

My problem right now is that when inserting a node with one date, it
appears as "day before" when viewing the node. How should I save it to
avoid this problem?

My form looks like
&nbsp;$arrayF=getdate(($node-&gt;data_paper&gt;0 ? $node-&gt;data_paper : time()));
&nbsp;$arrayF['month']=$arrayF['mon'];
&nbsp;$arrayF['day']=$arrayF['mday'];
&nbsp;$form['data_paper_array'] = array(
&nbsp; &nbsp;'#type' =&gt; 'date',
&nbsp; &nbsp;'#title' =&gt; 'Data Factura',
&nbsp; &nbsp;'#default_value' =&gt; $arrayF,
&nbsp; &nbsp;'#required' =&gt; TRUE,
&nbsp; &nbsp;'#weight' =&gt; -9,
&nbsp;);

My insert query looks like
&nbsp;$dateF=$node-&gt;data_paper_array;
&nbsp;$factura_tmsp=mktime(0,0,0,$dateF['month'],$dateF['day'],$dateF['year']);//
&nbsp;$date['year']."-".$date['month']."-".$date['day'];
&nbsp;$node-&gt;data_paper=$factura_tmsp;
&nbsp;db_query("INSERT ......);

And my theme function:
&nbsp;$output.="&lt;li&gt;&lt;b&gt;Data Factura:&lt;/b&gt;
".format_date($node-&gt;data_paper,'small')."&lt;/li&gt;";


Any hint/advice? Thanks

--
*La vida &eacute;s com una taronja, qu&egrave; esperes a exprimir-la?
*Si creus que l'educaci&oacute; &eacute;s cara, prova la ignor&agrave;ncia.
*La vida &eacute;s com una moneda, la pots gastar en el que vulguis per&ograve;
nom&eacute;s una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.




    </pre>
  </blockquote>
  <pre wrap=""><!---->


  </pre>
</blockquote>
</body>
</html>