Topic
  • 10 replies
  • Latest Post - ‏2012-12-28T04:30:09Z by SystemAdmin
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic TimeStamp Format

‏2012-10-23T03:33:16Z |
Hi

I am trying to insert current time stamp value in the body.

Could anyone please let me know what function i need to use in order get the value in the following format

<timestamp>2012-10-22 07:07:10.458</timestamp>

Timestamp format *yyyy-mm-dd hh:mm:sshttp://.fffffffff*'
(example : '*2012-10-22 07:07:10.458*')

Thanks,
SS
Updated on 2012-12-28T04:30:09Z at 2012-12-28T04:30:09Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: TimeStamp Format

    ‏2012-10-23T03:38:45Z  
    Time stamp format -> yyyy-mm-dd hh:mm:ss.fractions
    example -> 2012-10-16 07:07:10.458
  • HermannSW
    HermannSW
    4903 Posts

    Re: TimeStamp Format

    ‏2012-10-23T12:55:04Z  
    Time stamp format -> yyyy-mm-dd hh:mm:ss.fractions
    example -> 2012-10-16 07:07:10.458
    Several solution on "timestamp with milliseconds" have been posted in this Forum.
    This is a solution on how to take timezone into account in addition:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14809526#14846798

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: TimeStamp Format

    ‏2012-10-24T15:50:54Z  
    • HermannSW
    • ‏2012-10-23T12:55:04Z
    Several solution on "timestamp with milliseconds" have been posted in this Forum.
    This is a solution on how to take timezone into account in addition:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14809526#14846798

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Hi Herman,

    according to my requirement I have to generate only 2012-10-24 15:21:59.39
    but when i am using the code as you mentioned I am getting 2012-10-24T15:21:59:39

    Please advice.
  • Liv2luv
    Liv2luv
    573 Posts

    Re: TimeStamp Format

    ‏2012-10-24T16:30:58Z  
    Hi Herman,

    according to my requirement I have to generate only 2012-10-24 15:21:59.39
    but when i am using the code as you mentioned I am getting 2012-10-24T15:21:59:39

    Please advice.
    I would try:

    <xsl:value-of select="translate('2012-10-24T15:21:59:39','T',' ')"/>
  • HermannSW
    HermannSW
    4903 Posts

    Re: TimeStamp Format

    ‏2012-10-24T19:48:17Z  
    • Liv2luv
    • ‏2012-10-24T16:30:58Z
    I would try:

    <xsl:value-of select="translate('2012-10-24T15:21:59:39','T',' ')"/>
    Suresh is right, see it in action here (for US eastern time):
    $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" -
    2012-10-24 15:47:15:44
    $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" -
    2012-10-24 15:47:15:619
    $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" -
    2012-10-24 15:47:16:131
    $
    


     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:46:58Z at 2014-03-25T02:46:58Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: TimeStamp Format

    ‏2012-10-24T20:17:13Z  
    • HermannSW
    • ‏2012-10-24T19:48:17Z
    Suresh is right, see it in action here (for US eastern time):
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">$ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" - 2012-10-24 15:47:15:44 $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" - 2012-10-24 15:47:15:619 $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" - 2012-10-24 15:47:16:131 $ </pre>

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Thanks Hermann and Suresh for your inputs. it's working now.
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: TimeStamp Format

    ‏2012-12-27T20:12:19Z  
    • HermannSW
    • ‏2012-10-24T19:48:17Z
    Suresh is right, see it in action here (for US eastern time):
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">$ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" - 2012-10-24 15:47:15:44 $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" - 2012-10-24 15:47:15:619 $ echo "<x/>" | xpath++ "translate(concat(date:add('1969-12-31T20:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000), 'T', ' ')" - 2012-10-24 15:47:16:131 $ </pre>

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Hi,

    I can able to generate time stamp what exactly I needed (ex: 2012-12-27 10:55:47.509)
    but time value populating 1 hour ahead then current time.

    I was triggered transaction at 2012-12-27 10:55:47.509
    but output populating 2012-12-27 11:55:47.509
    any thoughts?
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: TimeStamp Format

    ‏2012-12-27T20:13:10Z  
    adding 1 extra to current time
  • HermannSW
    HermannSW
    4903 Posts

    Re: TimeStamp Format

    ‏2012-12-27T23:25:57Z  
    adding 1 extra to current time
    If you used '1969-12-31T20:00:00' as in above samples, then please use '1969-12-31T19:00:00' to adjust.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: TimeStamp Format

    ‏2012-12-28T04:30:09Z  
    • HermannSW
    • ‏2012-12-27T23:25:57Z
    If you used '1969-12-31T20:00:00' as in above samples, then please use '1969-12-31T19:00:00' to adjust.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Thank you.!