Results 1 to 6 of 6

Thread: How to use Dates and Times in XForms?

  1. #1
    Join Date
    Jun 2009
    Posts
    360

    How to use Dates and Times in XForms?

    hi friends,
    Your last time help was really very appreciable and my query was solved. Thanks to all the guys that helped me by providing the correct solution. Now I have turned towards the PHP programming language. I am just starting with the basic programs of PHP. I want to know about the Date and Time that are using PHP. I have used date and time functions in other programming language but I don't know about the PHP. So please tell me how to use Dates and Times in XForms? Thanks in Advance !!
    Last edited by Zavier; 03-03-2010 at 05:57 AM.

  2. #2
    Join Date
    Mar 2008
    Posts
    349

    Re: How to use Dates and Times in PHP?

    XForms adds four more functions for converting dates into individual pieces such as years and months. The following are the functions that converts that :
    1. days-from-date()
    2. seconds-from-dateTime()
    3. seconds()
    4. months()

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How to use Dates and Times in PHP?

    I would like to explain the functions that are mentioned by the 'Warner'. The days-from-date() and seconds-from-dateTime() function operate on date-times. So you can use that on the output of now() as well as on date values input by the user or supplied by the form itself. Whereas the seconds() and the months() functions operate on durations. Hope that you got some useful information from this reply.!!

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to use Dates and Times in PHP?

    By using the days-from-date function, you can convert the date in the form 2008-08-22T08:54:21-05:00 or 2008-08-30 into the number of days that have elapsed since January 1, 1970. You can use this to calculate the difference between two dates or the amount of time that has passed. The following coding demonstrates the same :
    HTML Code:
    html xmlns="URL/xhtml" 
          xmlns:xforms="URL1/xforms">
       <head>
        <title>Days until Christmas</title>
        <xforms:model>
         <xforms:instance xmlns="">
          <variables>
            <Now/>
            <Year/>
            <Christmas/>
            <ChristmasDay/>
            <Result/>
          </variables>
         </xforms:instance>
    
        <xforms:bind nodeset="Now" calculate="days-from-date(now())"/>
        <xforms:bind nodeset="Year" calculate="substring(now(), 1, 4)"/>
        <xforms:bind nodeset="Christmas" calculate="concat(../Year, '-12-25')"/>
        <xforms:bind nodeset="ChristmasDay" calculate="days-from-date(../Christmas)"/>
        <xforms:bind nodeset="Result" calculate="../ChristmasDay - ../Now"/>
    
        </xforms:model>
       </head>
       <body>
        <h1>
          <xforms:output value="Result">
            <xforms:label>Days until Christmas: </xforms:label>
          </xforms:output>
        </h1>
       </body>
    </html>
    You can use the above form for an XForm that counts the days remaining until Christmas.

  5. #5
    Join Date
    Nov 2008
    Posts
    996

    Re: How to use Dates and Times in PHP?

    The seconds-from-dateTime function converts a date in the form 2008-08-30T08:54:21-05:00 into the number of seconds that have elapsed since midnight, January 1, 1970. For example, this output element counts the seconds remaining until Christmas :
    Code:
    <xforms:output value="seconds-from-dateTime(
      concat(substring(now(), 1, 4), '-12-25T00:00:00-05:00')) 
      - seconds-from-dateTime(now())">
       <xforms:label>Seconds until Christmas: </xforms:label>
    </xforms:output>
    Seconds-from-dateTime returns NaN if it can't convert the string to a date.

  6. #6
    Join Date
    Jul 2006
    Posts
    289

    Re: How to use Dates and Times in XForms?

    The seconds() function operates on durations rather than datetimes. The months() function also operates on durations. The following are some more functions related to the Date and Time in XForms :
    1. local-date()
    2. local-dateTime()
    3. now()
    4. days-to-date()
    5. seconds-to-dateTime()
    Signatures reduce available bandwidth

Similar Threads

  1. Replies: 2
    Last Post: 13-02-2011, 12:25 AM
  2. What are the Properties of XForms?
    By Rob Dizzle in forum Software Development
    Replies: 4
    Last Post: 03-03-2010, 06:59 AM
  3. What are the Selection Controls of XForms?
    By super soaker in forum Software Development
    Replies: 4
    Last Post: 03-03-2010, 06:37 AM
  4. What are the XForms and XPath?
    By Nathen in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 05:35 AM
  5. How to use XForms in PHP?
    By Xylina in forum Software Development
    Replies: 4
    Last Post: 03-03-2010, 02:43 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,422,444.63979 seconds with 16 queries