Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how do i get IST Zone time format.

how do i get IST Zone time format.

Scheduled Pinned Locked Moved ASP.NET
htmlhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shiva kore
    wrote on last edited by
    #1

    Hi all, i have created html reports and displayed date by using DateTime.now.Tostring("dd-mm-yyyy") but it shows US time Zone's time but i wann display it in IST +5:30 format can u pls help me... Thanks and regards.

    J A 2 Replies Last reply
    0
    • S shiva kore

      Hi all, i have created html reports and displayed date by using DateTime.now.Tostring("dd-mm-yyyy") but it shows US time Zone's time but i wann display it in IST +5:30 format can u pls help me... Thanks and regards.

      J Offline
      J Offline
      JimBob SquarePants
      wrote on last edited by
      #2

      Are you just wanting to add 5:30 to your local time? The simplest way would be to just code.

      DateTime.Now.AddHours(5.5).Tostring("dd-mm-yyyy")

      If you were wanting to make it more flexible I would suggest setting the value to add to a settings file or to your web.config so you wouldn't have to update the code everywhere should you change the location of your server.

      JimBob SquarePants ******************************************************************* "He took everything personally, including our royalties!" David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager *******************************************************************

      1 Reply Last reply
      0
      • S shiva kore

        Hi all, i have created html reports and displayed date by using DateTime.now.Tostring("dd-mm-yyyy") but it shows US time Zone's time but i wann display it in IST +5:30 format can u pls help me... Thanks and regards.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        I think either you need to configure your local time of the system to IST or adjust the time programmatically. Use DateTime.Now.ToUniversalTime().AddHours(5).AddMinutes(30) Also to get the format right, place Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("culturecode"); before your DateTime call. I hope you will get the result. :-D

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Windows7 API Code Pack
        Simplify Code Using NDepend
        Basics of Bing Search API using .NET

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups