What is the difference between gmt() and local()?

I have written

1. gmt(now(),"IST")

2. local(now(),"IST")

local() function shows correct time as per local timestamp, but gmt is showing +1 hour in my current time. Anyone can explain why?

  Discussion posts and replies are publicly visible

Parents
  • Hi Khemraj Soni ,

    Here gmt() and local() functions both does not store a time zone offset with the returned values.
    gmt() :Subtracts a time zone offset from a given Date and Time
    Ex: gmt(datetime(2011, 12, 13, 12, 05), "GST") returns 12/13/2011 2:05 AM GMT+00:00 and if the time zone changes to some thing else
    like
    gmt(datetime(2011, 12, 13, 12, 05), "America/New_York") returns 12/13/2011 5:05 PM GMT+00:00 Where as for local()

    local():
    Ex: local(datetime(2011, 12, 13, 12, 05), "America/New_York") returns 12/13/2011 7:05 AM GMT+00:00,

    local(datetime(2011, 12, 13, 12, 05), "GMT") returns 12/13/2011 12:05 PM GMT+00:00 .

    Thanks,
    ravalik
Reply
  • Hi Khemraj Soni ,

    Here gmt() and local() functions both does not store a time zone offset with the returned values.
    gmt() :Subtracts a time zone offset from a given Date and Time
    Ex: gmt(datetime(2011, 12, 13, 12, 05), "GST") returns 12/13/2011 2:05 AM GMT+00:00 and if the time zone changes to some thing else
    like
    gmt(datetime(2011, 12, 13, 12, 05), "America/New_York") returns 12/13/2011 5:05 PM GMT+00:00 Where as for local()

    local():
    Ex: local(datetime(2011, 12, 13, 12, 05), "America/New_York") returns 12/13/2011 7:05 AM GMT+00:00,

    local(datetime(2011, 12, 13, 12, 05), "GMT") returns 12/13/2011 12:05 PM GMT+00:00 .

    Thanks,
    ravalik
Children