Php input date/time as timestamp with timezone

This is a nightmare!!!!
I have numerous databases, all of which use timestamp format
date/times, which are easy to echo according to user timezone
preferences using putenv ("TZ=".$_SESSION['MM_UTZ']); and echo
date($_SESSION['MM_UTF'], ($whatever));
The only problem is, I have only used these for stamping
"date created" or "date edited" values using Time()
What I am trying to achieve is:
User 1 in UK enters date and time, using a javascript
datetime picker (which normally enters data into field in Y-m-d
H:i:s) and the php inserts this in timestamp format according to
timezone.
User 2 in US looks at date and time and this is echo'd
according to his timezone.
Sounds simple...
I have managed to get so far with the new DateTime object
which incorporates the user timezone preference ($utz)
$ndttime= new DateTime($timefield, new DateTimeZone($utz));
I can then echo this effectively using
echo $ndttime->format('$utf'); ($utf being user timeformat
preference)
My stupid problem is trying to get the $ndtime into the
database!!!!
I know this sounds ridiculous but I use the DW insert wizard
which only uses values from a form and if I echo $ndtime into a
hidden field, it doesn't process this value in time.
I attach the current insert script.
Is this simple?
Heeeeelp.

quote:
Originally posted by:
AXEmonster
how does this format when you echo to the page
echo $ndttime->format('$utf');
This will echo as a date/time object - i.e. Y-m-d H:i:s, but
the $utf variable is a session variable with user time format
preferences, so it could be D, d/m/Y H:i:s or m-d-Y H:i:s
etc.

Similar Messages

  • Oracle ODBC driver and TIMESTAMP with timezone

    Does anyone know if it is possible to return data from a "TIMESTAMP WITH TIMEZONE" column using the Oracle ODBC driver and an ADO Recordset?
    I am using the Oracle driver version 10.2.0.2 and TIMESTAMP fields work fine.
    I can call Recordset->Open() with a query like "SELECT * FROM TABLE" when the table contains a column of type timestamp with timezone but when I execute a statement to see if there are results as in
    if (!(srcRecsetPtr->BOF && srcRecsetPtr->EndOfFile))
    my application throws an unhandled exception and exits. The exception is not a COM exception and I'm not sure how to get back additional information if that's possible.
    The only information I've been able to find in searching TechNet and MetaLink is that a workaround is to wrap the columns in a TO_CHAR or TO_DATE conversion first but that's not a good solution for my problem since I am executing user specified SQL which may join multiple tables.
    I've found one other note that says the documentation should be corrected and that these fields are NOT supported period (Bug #4011640).
    I've experimented with the Bind Timestamp as Date option in the ODBC connection and with various ALTER SESSION settings to attempt to change the NLS_TIMESTAMP_TZ_FORMAT but I have been unable to get past the problem.
    Any ideas are greatly appreciated.
    Thanks,
    Troy

    Hi Justin
    Thanks for your help.
    I tried what you mentioned and I could connect myself via SQL*Plus without passing a password and a login, Extern authentification seems to work and my user seems to be right configurated.
    But he problem goes on via ODBC. When I test connection in the ODBC Data Source Administrator of Windows XP, test fails and seems to forbid connection without userID and password. When I try to connect via ODBC in my program the same problem appears : "Unable to connect SQLSTATE=28000 [Oracle][ODBC][ORA]Ora-01017: Invalid username/password;logon denied" I could not connect in this way.. What's wrong ?

  • Regarding timestamp with timezone

    Hi,
    I have the following timestamp with timezone issue.
    From java program I am passing the datetime with timezone value to database (INTERVALTIME (column name)).
    PrepareStatemenet statement;
    java.util.Date dt = ISODateUtil.parse("2006-06-21T18:00:00+00:00");
    SimpleTimeZone zone = new SimpleTimeZone(0,"IST");
    Calendar cal = converting the dt to calendar;
    cal.setTimeZone(zone);
    statement.setTimestamp(col, new Timestamp(cal.getTimeInMillis()),cal);     
    In database INTERVALTIME (column name) coulmn type is TiMESTAMP WITH TIMEZONE.Database is in PDT (GMT-8) timezone.
    Now the problem is :
    Even if i send the datetime of IST timezone, it is displaying in PDT (GMT-8) timezone.
    How can i resolve this issue?

    Reo wrote:
    The query you provided doesn't run. If I want to convert to a different timezone, I need the from_tz.Is column update_time a TIMESTAMP WITH TIME ZONE? If so, then no casting is needed:
    SQL> create table test(id number,update_time timestamp with time zone)
      2  /
    Table created.
    SQL> insert into test values(1,systimestamp)
      2  /
    1 row created.
    SQL> insert into test values(2,systimestamp  at time zone 'UTC')
      2  /
    1 row created.
    SQL> select  id,
      2          update_time,
      3          update_time at time zone 'US/Pacific'
      4    from test
      5  /
            ID
    UPDATE_TIME
    UPDATE_TIMEATTIMEZONE'US/PACIFIC'
             1
    18-NOV-09 04.23.03.241000 PM -05:00
    18-NOV-09 01.23.03.241000 PM US/PACIFIC
             2
    18-NOV-09 09.23.29.346000 PM UTC
    18-NOV-09 01.23.29.346000 PM US/PACIFIC
            ID
    UPDATE_TIME
    UPDATE_TIMEATTIMEZONE'US/PACIFIC'
    SQL> SY.

  • Why have I lost the info of  timezone (Timestamps with Timezone )

    I have been trying to get timestamps with timezones working in my Java application, but I don't seem to get the data I expect back from the JDBC driver
    my field type is Timestamps with Timezone ,in the database,I saw the info of (12-DEC-06 01.12.12.123000 PM -06:00),but I don't know How to get it from Java
    I've use the Timestamp aa =rs.getTimestamp("FIELDVALUE");but the timezone is lost, what can I do?
    thanks

    Timestamps are always GMT based (or could be thought of as timezone neutral) so what you should get back is a timestamp representing a GMT equivalent of the time you see that has a 6 hour offset from GMT. In other words, if the time were 1 PM Central Standard you would get a GMT time of 7 PM.
    You should then be able to display that time in any time zone you wish using SimpleDateFormat and specifying the time zone you want to display it in. So if you then display it with Central Standard, the 7 PM GMT would then display as 1 PM again. In other words, 7 PM GMT and 1 PM Central Standard are the same timestamp
    If you just display the timestamp using a toString(), you will get the time in the default time zone of the JVM..
    Whether the driver actually does this correctly with the Oracle database I can't say. I've made several posts in a variety of places complaining that the driver does not work correctly with timestamps but my experience is limited to regular timestamp fields, not the new Oracle type of timestamp with timezone.
    Based on my experience, what you are more likely getting back in the 1 PM- 7 PM example is 7 PM in the default timezone of the JVM.
    You should look at the getTimestamp with Calendar options to see if they work better for you.
    The main thing to keep in mind is that timestamps are really timezone neutral.

  • Compare 2 'timestamp with timezone' columns

    Hi All,
    I'm trying to compare 2 'timestamp with timezone' columns,
    comparision works fine as long as there is difference of at least seconds between them.
    But when the difference between them is in milliseconds, comparison is failing.
    I'm using oracle 10g.
    Pls advice.

    Works just fine:
    SQL> DECLARE
      2      t1 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:17.123456 US/EASTERN';
      3      t2 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:17.323456 US/EASTERN';
      4  BEGIN
      5      IF t1 <= t2
      6        THEN
      7          DBMS_OUTPUT.PUT_LINE('t1 <= t2');
      8      END IF;
      9  END;
    10  /
    t1 <= t2
    PL/SQL procedure successfully completed.
    SQL> DECLARE
      2      t1 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:16.123456 US/EASTERN';
      3      t2 TIMESTAMP WITH TIME ZONE := TIMESTAMP '2008-01-10 10:25:17.323456 US/EASTERN';
      4  BEGIN
      5      IF t1 <= t2
      6        THEN
      7          DBMS_OUTPUT.PUT_LINE('t1 <= t2');
      8      END IF;
      9  END;
    10  /
    t1 <= t2
    PL/SQL procedure successfully completed.
    SQL> Based on your:
    But when the difference between them is in milliseconds, comparison is failing. Most likely your code does implicit/explicit timestamp conversion to date. Post your code.
    SY.

  • Oracle timestamp with timezone

    Does CR support column of type "timestamp with timezone" column. I am getting error message "Failed to retrive data from database. Details:Not implemented". Thanks

    Since this is the Crystal Reports Java forum, you need to specify the explicit Java java.sql Type that the Oracle JDBC driver exposes the database type as.
    I'm not familiar with that data type, so don't know if it's mapped to the Timestamp type or not.
    Note that CR4E 2.0 supports up to JDBC 4.0 types.
    Sincerely,
    Ted Ueda

  • Converting timestamp with timezone to milisecs

    Hi guys,
    How to converting timestamp with timezone to milisecs?
    I'm using oracle 10g.

    SeánMacGC wrote:
    Hello, do you mean:
    SQL> select to_char(systimestamp, 'SSSSS') from dual;
    TO_CH
    58435
    'SSSSS' Format Model returns 'Seconds past midnight' not milliseconds. I wonder if OP meant Fractional Seconds?
    SQL> SELECT TO_TIMESTAMP_TZ('1999-12-01 11:00:00.00532 -8:00',
      2         'YYYY-MM-DD HH:MI:SS.FF TZH:TZM') col_1 FROM DUAL
      3  /
    COL_1
    01-DEC-99 11.00.00.005320000 AM -08:00
    SQL> SELECT TO_CHAR(col_1, 'FF') fractional_sec FROM
      2  (SELECT TO_TIMESTAMP_TZ('1999-12-01 11:00:00.00532 -8:00',
      3         'YYYY-MM-DD HH:MI:SS.FF TZH:TZM') col_1 FROM DUAL)
      4  /
    FRACTIONA
    005320000
    SQL>Regards,
    Jo
    Edited by: Joice John : Added Code Tags

  • Unique or primary key on timestamp with timezone

    Hi,
    I have been experimenting with a date column in a primary key, or actually I tried using a timestamp with time zone in a primary key.
    While researching whether there was a way to avoid ORA-02329, I found the following:
    K15> create table dumdum
      2    (datum date not null
      3    ,naamp varchar2( 30 ) not null);
    Table created.
    K15>
    K15> alter table dumdum
      2    add constraint d_pk
      3        primary key
      4          (datum, naamp)
      5    using index;
    Table altered.
    K15>
    K15> select ind.index_type
      2  from   user_indexes ind
      3  where  ind.index_name = 'D_PK';
    INDEX_TYPE
    NORMAL
    1 row selected.
    K15>
    K15> insert into dumdum
      2    (datum
      3    ,naamp )
      4  select sysdate - (level/1440)
      5  ,      'nomen nescio'
      6  from   dual
      7  connect by level < 1000
      8  ;
    999 rows created.
    K15>
    K15> analyze index d_pk validate structure;
    Index analyzed.
    K15> analyze table dumdum compute statistics;
    Table analyzed.
    K15>
    K15> select naamp
      2  from   dumdum
      3  where  datum > to_date('16-06-2011 15.46.16', 'dd-mm-yyyy hh24.mi.ss' )
      4 
    K15> For the last select statement I get the following "explain plan":
    SELECT STATEMENT  CHOOSE
              Cost: 2  Bytes: 247  Cardinality: 13       
         1 INDEX RANGE SCAN UNIQUE D_PK
                    Cost: 3  Bytes: 247  Cardinality: 13  This behavior lived up to my expectations.
    Then, I tried this:
    K15> create table dumdum
      2    (datum date not null
      3    ,naamp varchar2( 30 ) not null);
    Table created.
    K15>
    K15> alter table dumdum
      2    add constraint d_pk
      3        primary key
      4          (datum, naamp)
      5    using index;
    Table altered.
    K15>
    K15> alter table dumdum
      2        modify datum timestamp(6) with time zone;
    Table altered.
    K15>
    K15> select ind.index_type
      2  from   user_indexes ind
      3  where  ind.index_name = 'D_PK';
    INDEX_TYPE
    NORMAL
    1 row selected.
    K15>
    K15> insert into dumdum
      2    (datum
      3    ,naamp )
      4  select sysdate - (level/1440)
      5  ,      'nomen nescio'
      6  from   dual
      7  connect by level < 1000
      8  ;
    999 rows created.
    K15>
    K15> analyze index d_pk validate structure;
    Index analyzed.
    K15> analyze table dumdum compute statistics;
    Table analyzed.
    K15>
    K15> select naamp
      2  from   dumdum
      3  where  datum > to_date('16-06-2011 15.46.16', 'dd-mm-yyyy hh24.mi.ss' )
      4
    K15> So, at first glance, the alter table statement to change the datatype from DATE to TIMESTAMP seems like a way of fooling Oracle. But the explain plan reveals a different story:
    SELECT STATEMENT  CHOOSE
              Cost: 4  Bytes: 1,25  Cardinality: 50       
         1 TABLE ACCESS FULL DUMDUM
                    Cost: 4  Bytes: 1,25  Cardinality: 50  I was only fooling myself. :-0
    But I wasn't done with my research:
    K15> create table dumdum
      2    (datum timestamp(6) with time zone not null
      3    ,naamp varchar2( 30 ) not null);
    Table created.
    K15>
    K15> create unique index d_ind
      2      on dumdum
      3           (datum, naamp);
    Index created.
    K15>
    K15>
    K15> select ind.index_type
      2  from   user_indexes ind
      3  where  ind.index_name = 'D_IND';
    INDEX_TYPE
    FUNCTION-BASED NORMAL
    1 row selected.
    K15>
    K15> insert into dumdum
      2    (datum
      3    ,naamp )
      4  select systimestamp - (level/1440)
      5  ,      'nomen nescio'
      6  from   dual
      7  connect by level < 1000
      8  ;
    999 rows created.
    K15>
    K15> analyze index d_ind validate structure;
    Index analyzed.
    K15> analyze table dumdum compute statistics;
    Table analyzed.
    K15>
    K15> select naamp
      2  from   dumdum
      3  where  datum > to_date('16-06-2011 15.56.16', 'dd-mm-yyyy hh24.mi.ss' )
      4
    K15>Now, my explain plan looks fine:
    SELECT STATEMENT  CHOOSE
              Cost: 2  Bytes: 1,25  Cardinality: 50       
         1 INDEX RANGE SCAN UNIQUE D_IND
              Cost: 3  Bytes: 1,25  Cardinality: 50  Why is Oracle so adamant about not allowing a timestamp with time zone in a unique key? And, given their position on the matter, where does their tolerance for a unique index come from?
    By the way, if I had a say in it, I would not allow anything that even remotely looks like a date to be part of a primary key, but that's another discussion.
    Thanks,
    Remco
    P.S. All this is on Oracle9i Enterprise Edition Release 9.2.0.8.0. Is it different on 10g or 11g?

    See if this helps. You can create primary key for TIMESTAMP WITH LOCAL TIME ZONE datatype.
    SQL>CREATE TABLE Mytimezone(Localtimezone TIMESTAMP WITH LOCAL TIME ZONE primary key, Location varchar2(20) );
    Table created.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006169
    TIMESTAMP WITH LOCAL TIME ZONE Datatype
    TIMESTAMP WITH LOCAL TIME ZONE is another variant of TIMESTAMP. It differs from TIMESTAMP WITH TIME ZONE as follows: data stored in the database is normalized to the database time zone, and the time zone offset is not stored as part of the column data. When users retrieve the data, Oracle returns it in the users' local session time zone. The time zone offset is the difference (in hours and minutes) between local time and UTC (Coordinated Universal Time, formerly Greenwich Mean Time).
    Thanks
    http://swervedba.wordpress.com/

  • Best way to manage date/time variables across different timezones

    I have an application that relies heavily on time accuracy. At the moment everything is fine, but soon the system will service customers across multiple timezones. The default behavior of the Date class is to show dates related to the current timezone, is there an easy way (setting) to override this behaviour? The system should show the time entered regardless of the timezone it was entered on.
    I use CF 8 for the back-end, and MySQL 5.1 to store data. The front-end is Flex 3/Air 2.
    I have looked everywhere, and things like saving dates as strings, or long ints, but if possible, I'd like to find a solution that does not involve dramatic changes to my database/code.

    Thanks for your reply, UbuntuPenguin,
    Your explanation is correct and what I'm trying to find out is an easy way to override that behaviour.
    As an example of what the issue is, let's say an event was entered here, in Toronto,ON, at 3pm, if a customer in Arizona sees the time, he/she will call us immediately to inform us that the event it's supposed to happen at 3pm, and not at 12pm (time that they see with the different timezone).
    As far as I've seen, the "best" way to approach this issue is by using  the transient tag during data transfer and compensate for the time  difference in the client timezone vs the selected "system" timezone  using getters/setters, but that implies storing the wrong date/time and  locking the system into one timezone, and it's just a hack that may  bring undesirable consequences in the future.

  • Comparision of TIMESTAMP with TIMEZONE

    Hi,
    One of the column columnA is of timestamp datetype i.e value stored in it is '2007-09-20 04:00:00.0'
    I am using the following in SQL
    select * from tableA
    where columnA = TO_TIMESTAMP('2011-05-12 21:00:00','YYYY-MM-DD HH24:MI:SS').
    This is always returning null results..
    Is the syntax correct? Do I need to change the format to accept milli seconds?
    Thanks
    -Sree

    where columnA = TO_TIMESTAMP('2011-05-12 21:00:00','YYYY-MM-DD HH24:MI:SS').
    This is always returning null results..So there is no record with that exact date & time.
    Is the syntax correct?yes
    Do I need to change the format to accept milli seconds?no

  • LV 8.5.X: Converting String Data/Time to Timestamp

    Hello again,
    is there really no convenient way to convert a String Data/Time to an
    Timestamp?
    Thanks and greetings
    Udo

    You can use the Scan from String function:
    Look at the bottom for an example. If you can't get the format string right, you can configure a timestamp control/indicator to what you need and then use the properties (right click) then select Advanced at the bottom to get the string you need.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How to input data into a table with columns?

    I am trying to input data into a table.  My table have 5 columns and an unlimited amount of rows.  I created a program in LabView that enters the data into the table but it enters all of the data in one row.  I would like to enter the first set of information into the first column, the second set of info into the second  column and so on.  I am including a copy of the program that I am working with.  I would like the number of runs to be put into the first column (it should count down like number 5 in first row, number 4 in second row, number 3 in third row, and so on).  I would like the applied voltage to be placed in the second column, and so on.  Any help or information will be greatly appreciated.  I am working with LabView Version 6.1 and 8.0.  I am submitting the vi from 6.1. 
    Attachments:
    FJ-PROGRAM.vi ‏68 KB

    Pondered,
    I looked at your code and I think you might be making things too complicated. I've included a very simple example that demonstrates how to write a 2D array of integers to a table. Hope you find this helpful. It is in LV 7.1.
    Chris C
    Chris Cilino
    National Instruments
    LabVIEW Product Marketing Manager
    Certified LabVIEW Architect
    Attachments:
    rows - columns.vi ‏17 KB

  • Best way to store, present en input date/time

    Hi!
    I hope I can make myself clear. I'm designing an APEX application that has a couple of different date-type fields. That application is going to be translated in two different languages, that has different date/time representations. For example: dd-mon-yyyy hh12:miAM and dd-mm-yyyy hh24:mi. I'm now finding out what's the best way to store those date/time fields and hou I can present them in a report/form and how the user can enter them in a field.
    This is what I see:
    - I can set an application date format/application timestamp format. This has to be the in the format of the main language, in this case, English.
    - I also can make translated versions of the application. QUESTION: can I enter a different date format for the translated application?
    Do I have to make my fields of the date type or timestamp type?
    I hope someone can answer. If I'm not clear, please tell me!

    You can set the application date format using an application item
    &DATE_FORMAT_MASK.
    and set this item dynamically.
    Home>Application Builder>Application ####>Shared Components>Edit Globalization Attributes
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Production order confirmation date & time not matching with MB51.

    Hi All,
    We are facing a problem when we confirm production order in a local time zone but when we go and check the material document MB51 , we find the posting date and time is showing System date and time and not the local date and time - in the month end we are facing the problems in reports preperation.
    Please find the example as below-
    Step-1
    I do confirmation of Production order 101939015 for the Plant 2041
    on 03/12/2007 at 11:39:33 ( USER TIME ZONE),
    Step-2
    Now go to the MB51 (Material document list)and check the posting time
    - here the posting date and time is 03/11/2007 & 23:39:37. ( SYSTEM TIME ZONE.)
    Material Document Number : 4909412794
    From the above example we can see that the production order was confirmed in USER TIME ZONE ,but the document was posted in SYSTEM TIME ZONE, which is not acceptable to the USER, as in the month-end he is not getting the correct Reports. User wants a harmonized date & time.
    Can anybody give some solution its very urgent.
    Nitin.

    Hi Nitin,
    Can you check the confirmation time in the system by displaying confirmation and then there look for "Admin" data.
    Also let us know whether Confirmation/Goods Movment is online update or run in background as job?
    Please let us know your findings,
    Regards,
    Prasobh

  • Date & Time error 0271 with T-22

    I've had no problems with my T-22 which was upgraded to Windows XP and additional RAM was added about a year ago. It's been running fine and had no problems until about a week ago. When I went to turn it on I got an error 0271 "check date and time settings".  Since then I cannot get my computer to boot up. It will get to the point where it requires my password and when I type it in it says OK but won't go any further. I have tried everything but it won't let me into the BIOS setup utility to correct the date and time. I've downloaded diskettes and cds from the IBM website on my other computer and tried to boot up my T-22  (of course I didn't have the foresight to make a boot disk or cd) and tried the commercial softwarre such as Professional Mechanic, etc. but nothing works.  Does anyone have any ideas?

    Just removing the battery will do nothing to reset the systemboard remove the laptop battery and also the CMOS battery than with no power cord installed hold the power button for 30 seconds do this 3 times and the system is reset. EZ-Serv will tell you the same thing but for time and data error I stand by replacing the cmos

Maybe you are looking for