Date Time Convertion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dillipkumar
    New Member
    • Mar 2008
    • 41

    Date Time Convertion

    Hi,

    I have a string like: "2012-10-24T23:59:00.000 +05:30"

    I want to modify the above string into different time Zone.

    I have written a shell script, but it is not working properly.

    lSearchValueDat eTime='2012-10-24T23:59:00.000 +05:30'
    lSearchDateTime HmsZone=`echo $lSearchValueDa teTime|cut -c1-23`
    lModDateTimeHms Ms=`date +%FT%T.%N -d $lSearchDateTim eHmsZone|cut -c1-23` lModZone=`date +%:z -d $lModDateTimeHm sMs`

    NewDateTime=${l ModDateTimeHmsM s}${lModZone}

    echo $NewDateTime

    O/P: 2012-10-24T18:59:00.000 +02:00

    O/P should come like: 2012-10-24T20:29:00.000 +02:00

    Please help me to get the appropriate result.

    ~Thanks
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    The standard 'date' can do this:

    Code:
    ~> date
    Sat Jun  9 09:45:13 CEST 2012
    ~> date -d "2012-10-24T23:59:00.000+05:30" +%Y-%m-%dT%H:%M:%S%z
    2012-10-24T20:29:00+0200
    ~>
    
    ~> TZ='America/Los_Angeles' date -d "2012-10-24T23:59:00.000+05:30" +%Y-%m-%dT%H:%M:%S%z
    2012-10-24T11:29:00-0700
    Last edited by Luuk; Jun 9 '12, 07:53 AM. Reason: LA-time added

    Comment

    Working...