Convert date to GMT +5.30

Discussion in 'General Web Coding' started by oshoinfosys, Nov 13, 2008.

  1. oshoinfosys

    oshoinfosys Guppy

    Hi,
    I want to get date as input from users in Indian time ( +5.30 )
    I am using ASP

    thanks
  2. hafa

    hafa Perch

    I'm assuming that you're using VBscript. Since classic ASP/VB does not support UTC, the best way is to use MSSQL. This first bit will set up a recordset which calls the UTC date and time, adjusted to Mumbai (UTC/GMT + 5.3 hours). Be sure to change the cmd.ActiveConnection value:

    <%
    Dim rsdatetime
    Dim rsdatetime_cmd
    Dim rsdatetime_numRows

    Set rsdatetime_cmd = Server.CreateObject ("ADODB.Command")
    rsdatetime_cmd.ActiveConnection = your_connection_string
    rsdatetime_cmd.CommandText = "SELECT getutcdate() +.229 AS today"
    rsdatetime_cmd.Prepared = true

    Set rsdatetime = rsdatetime_cmd.Execute
    rsdatetime_numRows = 0
    %>

    You can then use the following in your form:

    <%=(rsdatetime.Fields.Item("today").Value)%>

    You can also use this directly in your script which creates the record if you don't want to incorporate it in a form element value. Don't forget to close the recordset at the end of it all:

    <%
    rsdatetime.Close()
    Set rsdatetime = Nothing
    %>

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services