locked
Get current date in gregorian even system regional settings changed RRS feed

  • Question

  • User-374433941 posted

    Hi i have this line of code to get current date value
    Format(DateTime.Now.Date, "yyyy/MM/dd")
    but this will get the date value according to current regional settings in my machine

    like i  change the regional settings to ar-Sa  i am getting the hijri date
    but i need if i change the regional settings also i want to get gregorian date

    Sunday, October 3, 2010 3:04 AM

Answers

  • User1564875471 posted

    The code in my first reply works well, i converted it to VB.NET for your reference:

    Dim departDate As DateTime = DateTime.Now
    Dim _d As String=departDate.ToString("yyyy/MM/dd", New CultureInfo("ar-JO"))




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 3, 2010 3:27 PM

All replies

  • User1564875471 posted

    This is how we do that in C#:

            DateTime dt = DateTime.Now;
            Response.Write(dt.ToString("yyyy/MM/dd", new CultureInfo("ar-JO")));

    Here i used arabic jordan culture which doesn't uses Hijri calendar.You can also use any other culture like en-US.

    Sunday, October 3, 2010 3:29 AM
  • User-374433941 posted


    now my current culture is ar-Sa

    Here i  am getiing the date as "1431/10/25" or i will get hijri date from hijri calender control 

    Dim departDate As String = Format(DateTime.Now.Date, "yyyy/MM/dd")

    here i want to convert  this hijri date into gregorian format

     Dim _d As String = departDate.ToString(New System.Globalization.CultureInfo("en-US"))

    Note now my current culture is ar-Sa

    Sunday, October 3, 2010 7:59 AM
  • User-374433941 posted

    Hi any onen post the write code for converting Hijri date to gregorian date

    Sunday, October 3, 2010 2:22 PM
  • User1564875471 posted

    The code in my first reply works well, i converted it to VB.NET for your reference:

    Dim departDate As DateTime = DateTime.Now
    Dim _d As String=departDate.ToString("yyyy/MM/dd", New CultureInfo("ar-JO"))




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 3, 2010 3:27 PM