Converting TimeStamp to usable date

I have been using this script, which seems to be all over the web, but keep getting a different date to what is in my database:
    <?php do { ?>
      <h3><?php echo $row_GetsNewsText['post_title']; ?></h3>
      <?php $datetime = $row_GetsNewsText['post_date'];
  $year = substr( $datetime, 0, 4 );
  $mon = substr( $datetime, 4, 2 );
  $day = substr( $datetime, 6, 2 );
  $hour = substr( $datetime, 8, 2 );
  $min = substr( $datetime, 10, 2 );
  $sec = substr( $datetime, 12, 2 );
  $orgdate = date('F jS, Y', mktime( $hour, $min, $sec, $mon, $day, $year ) );
  ?>
      <h4><?php echo $orgdate; ?><?php /*?><?php echo $row_GetsNewsText['post_date']; ?><?php */?></h4>
      <p><?php echo $row_GetsNewsText['post_content']; ?></p>
      <?php } while ($row_GetsNewsText = mysql_fetch_assoc($GetsNewsText)); ?>
I don't understand what the ORDER of the variables in $orgdate relates to? I have tried them in different orders which has variable effects, so this must be the key I guess?
The two entries SHOULD display:
January 8th, 2010        and      June 15th, 2010
But what I get is:
December 1st, 2009    and    December 6th, 2009
I keep seeing January = 1st and June = 6th, so presumably I am getting close???
I am sure it is something obvious, but can't find it.

colinwalton wrote:
Hi, in my effort to try to understand php more, can you possibly explain what this part " -> " of the script means please:
It's the operator used to access the methods or properties of an object.
DateTime() is a class, which is why it uses the new keyword. format() is one of the class's methods. There is an old-fashioned procedural equivalent, but it's recommended to use the object-oriented approach instead (http://docs.php.net/manual/en/datetime.format.php).
Time for you to start learning about classes and objects in PHP 5: http://docs.php.net/manual/en/language.oop5.php. There's a lot to absorb in that section. You don't need to learn it all, but it's useful to know how to use classes and objects. Most new features in PHP use objects, so it's an important subject.

Similar Messages

  • How to convert  Timestamp  into exact Date and Time(FM)

    Hi Gurus,
    could anyone tel me  ,
    e.g:20.11.2008:11:23:54am
    How to convert Time stamp  into exact Date and Time

    Hi,
    Following is one way of doing it
    Timestamp timeStamp = new Timestamp(Calendar.getInstance().getTimeInMillis());
              System.out.println(timeStamp);
              SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
              System.out.println(dateFormat.format(timeStamp));
              SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
              System.out.println(timeFormat.format(timeStamp));
    Output
    2008-11-20 11:59:35.693 -> Timestamp
    11/20/2008
    11:59:35
    Regards
    Ayyapparaj

  • Convert Char. to Master Data

    Hello Experts,
    I have a char. in the system. And I would like to convert it to  master data. Because I am going to add to an attribute.
    What should I do?

    Hi ,
    1- Go to Transaction RSD1 and Enter the technical name of your Info Object and select the change option .
    2- go to Master Data/ Text Tab of Info object .
    3- Select the check box With Master Data and if you need text of master data then select the With Texts check box also .
    You can select short ,medium and long text as per your need .
    4- Now you can see that Attribute Tab has been appeared for the Info object . You can enter display or navigation attribute as per your requirement .
    Do not forget to re-activate the info object again .
    Note : If your object is already used in Info provider , system will not allow to make above changes . So First remove it from Info provider and then do this changes .
    Hope it helps .
    Regards
    Vikas Sharma
    Robert Bosch

  • When I enable imatch on my iPhone 4s it takes approximately 30 minutes before other data fills 13.2gb of usable data. This problem does not occur when I manually sync music to my phone. Is this a common bug, and if so; is there a fix?

    When I enable imatch on my iPhone 4s it takes approximately 30 minutes before other data fills 13.2gb of usable data on the phone. This problem does not occur when I manually sync music to my phone only when I access imatch. Is this a common bug, and if so; is there a fix?

    yes it is. you can sign out of itunes account then sign back in. use http://support.apple.com/kb/ht1311 to sign out.

  • Convert string to a date

    Gurus,
    It would be highly appreciable if you could help me in knowing how to convert a string to date in obiee. I know we need to use CAST function. I don't have enough material to figure it out myself.
    Awaiting a reply.
    Thanks.

    Nico - Thanks for the link, this is very helpful. Please tell me what's wrong in the following code. Am enlcosing the code and the error.
    Code 1 :
    CAST(CAST('31-OCT-'||CAST(YEAR("Dim - MBS Loan"."CLOSING DATE") AS CHAR) AS CHAR) AS DATE)
    Error 1:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 25137, message: ORA-25137: Data value out of range at OCI call OCIStmtExecute: select distinct D1.c1 as c1, D1.c2 as c2, D1.c3 as c3,
    Code 2 :
    CAST('31-OCT-'||SUBSTRING(CAST(YEAR("Dim - MBS Loan"."CLOSING DATE") AS CHAR),3,2) AS DATE)
    Error 2:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1840, message: ORA-01840: input value not long enough for date format at OCI call OCIStmtExecute: select distinct D1.c1 as c1, D1.c2 as

  • How to convert from line chart data to CSV format

    Hi ,
    I am using Flex 3 and AS.
    I am getting data from MS SQL and display the data as line
    chart this is ok.
    But i want to convert this line chart data to CSV or .xsl
    format.I find one example in fourms the from data grid to CSV
    For this URL is
    http://www.abdulqabiz.com/blog/archives/flash_and_actionscript/datagriddataexporter.php
    But i want Line chart to CSV.Please help me.

    Line chart is a just a visual representation of some data
    that's sitting in your database. Isn't it? You load this in Flex,
    probably using HTTPService class, and pass it to some chart object.
    Now when use says that she needs it in CSV format, you're
    gonna have to send another request to the server to produce the
    same data, convert into CSV or XLS format and let user download it.
    Of course, if use doesn't want to download, you don't have to
    go to the server, at least for CSV format. You can convert the same
    data that used plot the chart to convert to CSV.
    Am I missing something here?
    ATTA

  • Problem in converting the String to Date with time zone GMT

    Hi,
    When I tried to convert the string 12/05/2009 to Date, the time zone is set to BST.On the other hand, for the date 12/12/2009, the time zone is set to GMT. What should I do to get the time zone as GMT all the time.?
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    String dateString = "12/05/2009";
    System.out.println(myDate.toString());

    I think you are all missing the point. java.util.Date objects always alway always store the date as the number of milliseconds since 1/1/1970 UTC so the only TimeZone they have its the implicit UTC. When you use the Date.toString() method the toString() method gets the default time zone from your environment and formats the data accordingly. This means that the same Date object will, by default, produce a different result for France and Australia and the US.
    So, if you have the date "12/5/2009" as a String then to convert it to a java.util.Date you must specify what TimeZone is implied. If it is your system time zone then you can just create a SimpleDateFormat object with the correct format and then use the parse() method to create the java.util.Date object and this will automatically be converted to UTC. If the date String represents some other time zone then you must explicitly set the time zone of the SimpleDateFormat object before parsing the string.
    The same approach applies when converting a java.util.Date object to a String. If you want anything other than your system time zone then you must explicitly tell the SimpleDateFormat what time zone you want the result formatted for.

  • Error when converting time stamp in date time time zone CST  in IC

    Hi Experts,
    We have recently upgraded from CRM 5.0 to CRM 2007. We are using IC WEB Employee interaction center.
    so when agent create service ticket in interaction center and close the ticket on same day we are getting an error saying Error when converting time stamp in date time time zone CST.
    we thought there may be problem while installing SAP CRM by basis team in time zone, but we did not find any problem.
    So please advice how to resolve this issue.
    Regards,
    Teja

    Hi Teja,
    I saw a similar message, and it was resolved by adding a timezone to the user profile defaults tab in SU3. I believe the system has been configured to convert between users' timezone and the system timezone, therefore it needs to know each users' timezone.
    Regards,
    Simon.

  • Cannot convert from java.util.Date to java.sql.Date

    In the below code am trying to get the current date and 60 days prior date:
    Date  todayDate;
              Date  Sixtydaysprior;
              String DATE_FORMAT = "MM/dd/yy";
              DateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
             Calendar cal = Calendar.getInstance();
              todayDate = sdf.parse(sdf.format(cal.getTime()));
              cal.add(Calendar.DATE, -60);
             Sixtydaysprior = sdf.parse(sdf.format(cal.getTime()));I have imported following files:
    <%@page
         import="java.util.Calendar,
                   java.text.SimpleDateFormat,
                   java.text.ParseException,
                            java.util.*"
    %>Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    Thanks.
    Edited by: MiltonDetroja on May 22, 2009 11:03 AM

    Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    I don't think this exception is thrown from the portion of code you have shown. As clearly specified in exception message, you cannot cast an instance of java.util.Date to java.sql.Date. you will need to do something like this
    java.util.Date today = new java.util.Date();
    long t = today.getTime();
    java.sql.Date dt = new java.sql.Date(t);

  • How can i get the timestamp of first data at continue sample mode?

    how can i get the timestamp of first data at  continue sample mode?
    6023e pci , and c++ code
    thanks !

    The tangent ist the derivative of the curve in that point. You can try to use a numerical derivative vi or keep it simple an approximate with a line through the adjacent points.
    Gabi
    7.1 -- 2013
    CLA

  • How can I convert from Modbus raw data to engineering units using a formula?

    Within Lookout, I have several Modbus numerical input types that do not have a linear corespondence to the Engineering values they represent.  How can I display these values accurately using a formula to convert from the raw data to an engineering value?

    I don't quite understand your reply.  I'm using Lookout 6.0.2, logged in as Administrator, in Edit Mode.  The Modbus object is named RTU06_SAV.  The Active member is 30002 with an alias of SAVfmSMT_RSL.
    Following your instructions, I opened Object Explorer and right-clicked on RTU06_SAV. 
    This opened a menu containing:  Refresh, Cut, Copy, Rename, Delete, Edit connections..., Edit Data Member Configuration, Configure Network Security and Properties.
    I assumed that I should select Edit Data Member Configuration, but maybe I'm wrong. 
    Within Data Member Configuration I can set up Linear Scaling between Raw data and Engineering data.  I know how to do that, but what I need to know is how to convert Raw data to Engineering data using a formula representing a non-linear transformation (such as a converion to a logarithmic value or perhaps a formula derived by fitting the formula to a curve on a calibration chart).
    Once I have this my Engineering data can be represented on a control panel as both a numeric value AND as a correctly reading Gauge.  It can also be properly represented on a HyperTrend graph.
    What do you suggest?

  • How to show timestamp along with date in LOV dropdown

    Hi,
    We have a requirement to show timestamp along with date as a display column in a LOV drop down. Type of the date column in VVO is set to timestamp. But still it is showing only date in the UI.
    But it is showing timestamp when we run it through AM. Is there any thing in to do in addition to display it in UI? Or it is not feasible? Please suggest me on this issue.
    Thanks in advance.
    Thanks,
    Santhosh

    The date format displayed in UI depends on applcore preference set for current user, try changing date format set for current user to include time along with date.

  • Smart forms convert to pdf binary data

    Dear All,
    I'm working on smart forms integrations with .net and  I need to send the smart forms PDF binary data though custom rfc .
    For that i'm  converting smart forms otf  data  to pdf in and pass this data  through rfc but this idata is is not wokring on .net guys when they are converting this on pdf..
    so is there any need of decoded smart forms otf data before passing through or i'm missing some basic step?
    Please guide me?
    Rg
    Anuj

    hi,
    Have a look on this wiki:
    [http://wiki.sdn.sap.com/wiki/display/Snippets/SmartformoutputtoPDFformat]
    And maybe this one could also interest you:
    [|http://wiki.sdn.sap.com/wiki/display/Snippets/SmartformtoMailasPDF+attachment]
    regards
    mickael

  • How to convert a string to date and then compare it with todays date???

    Hello.
    I want to set a format first for my dates
    DateFormate df = new SimpleDateFormate("yyyy-mm-dd");
    once this is done then I want to convert any string to date object in the above formate
    String str="2001-07-19";
    Date d = null;
    try{
    d = df.parse(s);
    }catch(ParseException pe) {
    pe.printStackTrace();
    First of all there is something wrong above,cus what I get for this is
    Fri Jan 19 00:07:00 MST 2001
    where as it should have been
    2001-07-19... to my understanding.
    once this part is done I need to get current date in the above set format and compare the
    current date and the date I set.
    I will appreciate the help.
    Thanks

    for the output part:
    a date is a point in time
    the output depends on the format you specify for output
    using for example a SimpleDateFormat.
    You only specified the format for parsing (which is independent for that of output) so java uses some default format ... see the DateFormat.format() method for details.
    for the comparison stuff, I just posted a little code snippet in this forum a few minutes ago.
    the hint is: Date.getTime() returns milliseconds after a fixed date
    hth Spieler

  • Convert varchar2 field into date formatted: DD-MON-YYYY

    Thanks in advance for anyone's help on this matter as I know it takes your time and expertise. I am pretty new to SQL but learning my way through it just have an issue with a text to date field conversion. It is an Oracle 10g database and I am writing in SQL. There is a field called Demand which is formatted in varchar2 format of ddmmyy. There is also a field that is formatted as a date called Payment which is formatted as DD-MON-YYYY.
    Essentially I need to do a simple Payment >= Demand, however as you can see that is some issue with that being a varchar2 field. Does anyone know if it is possible to do that type of expression against those two fields. Was thinking about possibly converting the varchar2 to a date but not sure how to get to that DD-MON-YYYY format.
    Also there are situations where this Demand field will often times be null as it would have never recieved any outbound correspondence in the past and would not have a date at all.
    Thanks
    Edited by: user10860766 on Aug 18, 2009 8:14 AM
    Edited by: user10860766 on Aug 18, 2009 8:19 AM

    Hi,
    It's hard to detect bad dates in pure SQL, especially if you need to be precise about when February 29 is valid.
    It's easy with a user-define function, like the one in [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=3669932&#3669932].
    Edited by: Frank Kulash on Aug 18, 2009 3:50 PM
    To create a stand-alone function:
    CREATE OR REPLACE FUNCTION     to_dt
    (     in_txt          IN     VARCHAR2                    -- to be converted
    ,     in_fmt_txt     IN     VARCHAR2     DEFAULT     'DD-MON-YYYY'     -- optional format
    ,     in_err_dt     IN     DATE          DEFAULT     NULL
    RETURN DATE
    DETERMINISTIC
    AS
    BEGIN
         -- Try to convert in_txt to a DATE.  If it works, fine.
         RETURN     TO_DATE (in_txt, in_fmt_txt);
    EXCEPTION     -- If TO_DATE caused an error, then this is not a valid DATE: return in_err_dt
         WHEN OTHERS
         THEN
              RETURN in_err_dt;
    END     to_dt
    /To use it:
    SELECT  primary_key  -- and/or other columns to identify the row
    ,       demand
    FROM    table_x
    WHERE   demand          IS NOT NULL
    AND     to_dt ( demand
               , 'DDMMYY'
               )          IS NULL;

Maybe you are looking for

  • Managing more than one Nano on single computer

    I own a nano and am thinking about getting my son one. I just want to make sure both Nano's can be managed on one computer without confusion about which songs go on what Nano, etc. Can someone help me out? Thanks!!

  • Acrobat 9 printing problem

    Here's the scenario: Created a 1-age document in InDesign CS4, text with one jpeg. Created PDF. Tried to print from Acrobat 9.1.0 (Mac 10.5.6) but get error "Could not Print Document" then "No Pages were Selected." Other jobs, created in InDesign CS4

  • Sleep - no pulsing light with lid open.

    I have been aware of this little teaser for some time - possibly from when SL was installed. The MBP does not appear to be going to sleep with the settings on Energy Saver. The screen dims correctly and the light comes on at the correct time - but it

  • System should not pick reserved stock

    Dear, MM Experts, i am sd Guy i want to block Reserved stock while creating sales order ex: 150 qty kept In reserve for customer , Total plant stock 1000 Now if user created sales order with 150 qty Normally system will pick 150 qty From reserved sto

  • Your Disk is Almost Full ... No it's not.  Why is OS X telling me this?

    OS X Warning: "Your Startup Disk is Almost Full.  You need to delte files to make more space." Ironically, the more files I have delted, the less available space I see in Disk Utility. I had 20 Gigs available when the message first appeared.  So I de