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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Date formate in asp.net using C# Urgent!!!!! [modified]

Date formate in asp.net using C# Urgent!!!!! [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelp
4 Posts 2 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.
  • A Offline
    A Offline
    Aashutoshkumar
    wrote on last edited by
    #1

    i am using a webservice in which a method is serach. i use this method which accept a argument of date type in dd/MM/yyyy formate. i have a textbox which accept the date from the user, when i convert textbox data into Datatime formate it converted into MM/dd/yyyy formate, but i have a requirement in dd/MM/yyyy formate of date type. please help me, i am using c#.Net 2003 -- modified at 0:29 Friday 6th October, 2006

    M 1 Reply Last reply
    0
    • A Aashutoshkumar

      i am using a webservice in which a method is serach. i use this method which accept a argument of date type in dd/MM/yyyy formate. i have a textbox which accept the date from the user, when i convert textbox data into Datatime formate it converted into MM/dd/yyyy formate, but i have a requirement in dd/MM/yyyy formate of date type. please help me, i am using c#.Net 2003 -- modified at 0:29 Friday 6th October, 2006

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      That's because the DateTimeFormat of the current CultureInfo is the MM/dd/yyyy. For more information, see ASP.NET Globalization and Localization[^]

      A 1 Reply Last reply
      0
      • M minhpc_bk

        That's because the DateTimeFormat of the current CultureInfo is the MM/dd/yyyy. For more information, see ASP.NET Globalization and Localization[^]

        A Offline
        A Offline
        Aashutoshkumar
        wrote on last edited by
        #3

        i have try this: string selectedLanguage = "en-GB"; UICulture = selectedLanguage ; Culture = selectedLanguage ; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage); Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage); System.IFormatProvider format = new System.Globalization.CultureInfo("fr-FR", true); string stringDate = "23/03/05"; DateTime DTddMMyyyy=DateTime.Parse(stringDate,format,System.Globalization.DateTimeStyles.None); the format of DTddMMyyyy is MM/dd/yyyy and i want it in dd/MM/yyyy as 23/03/2006. but the result should be in datetime data type. if i use datetime.tostring("dd/MM/yyyy") then it returns strinng type date. but i want the return type be datetime object not string/ i am using web service which take date in datetime format and in "dd/MM/yyyy" format. but in .Net the date type return or change or default format is "MM/dd/yyyy". so plz help me to find the solution. this phaze is final phase of my project and there i change ne thing like change in service provider then it effect my whole project so plz help me Ashutosh Kumar

        M 1 Reply Last reply
        0
        • A Aashutoshkumar

          i have try this: string selectedLanguage = "en-GB"; UICulture = selectedLanguage ; Culture = selectedLanguage ; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage); Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage); System.IFormatProvider format = new System.Globalization.CultureInfo("fr-FR", true); string stringDate = "23/03/05"; DateTime DTddMMyyyy=DateTime.Parse(stringDate,format,System.Globalization.DateTimeStyles.None); the format of DTddMMyyyy is MM/dd/yyyy and i want it in dd/MM/yyyy as 23/03/2006. but the result should be in datetime data type. if i use datetime.tostring("dd/MM/yyyy") then it returns strinng type date. but i want the return type be datetime object not string/ i am using web service which take date in datetime format and in "dd/MM/yyyy" format. but in .Net the date type return or change or default format is "MM/dd/yyyy". so plz help me to find the solution. this phaze is final phase of my project and there i change ne thing like change in service provider then it effect my whole project so plz help me Ashutosh Kumar

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          There are a couple of things that you might want to check when you run your code in debug mode and step through your code line by line: + You can check the DateTimeFormatInfo value at run time especially when the DTddMMyyyy object does not have the right format: + You can check the DTddMMyyyy object after the Parse method executes. Below are two examples that give me the correct DateTime object after the Parse method runs:

          //Example 1:
          string selectedLanguage = "en-GB";
          Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage);
          string stringDate = "23/03/05";
          DateTime DTddMMyyyy = DateTime.Parse(stringDate);

          //Example 2:
          string selectedLanguage = "en-US";
          CultureInfo culture = new CultureInfo(selectedLanguage, true);
          //Here you can configure the DateTimeFormatInfo in the way you want.
          culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
          Thread.CurrentThread.CurrentCulture = culture;
          string stringDate = "23/03/05";
          DateTime DTddMMyyyy = DateTime.Parse(stringDate);

          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