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. General Programming
  3. C#
  4. DateTime.Now.ToLongDateString()

DateTime.Now.ToLongDateString()

Scheduled Pinned Locked Moved C#
question
8 Posts 4 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.
  • M Offline
    M Offline
    Member 3879881
    wrote on last edited by
    #1

    Hi all other system giving DateTime.Now.ToLongDateString() as Wednesday, July 28, 2010 But my system giving 28 July 2010 wht is the probs, y its giving like tht?, To get asusal like others system dateformat where i should change in my PC? Thanks & Regards, Member 3879881, please don't forget to vote on the post

    OriginalGriffO L 2 Replies Last reply
    0
    • M Member 3879881

      Hi all other system giving DateTime.Now.ToLongDateString() as Wednesday, July 28, 2010 But my system giving 28 July 2010 wht is the probs, y its giving like tht?, To get asusal like others system dateformat where i should change in my PC? Thanks & Regards, Member 3879881, please don't forget to vote on the post

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      You could - but you don;'t need to. The default DateTime.ToString method returns whatever your PC is set to, but you can tell it to return exactly what you want. See Here[^] for full details.

      Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      M 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        You could - but you don;'t need to. The default DateTime.ToString method returns whatever your PC is set to, but you can tell it to return exactly what you want. See Here[^] for full details.

        Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

        M Offline
        M Offline
        Member 3879881
        wrote on last edited by
        #3

        Hi Griff, Thanks for ur reply, I already created lot of project in the same way..., So i cant go and modify all the project place the date format like (MM/dd/YYY)..., If i change on single place(PC), it will work for all projects..., Thats y asking, where to change the date format in PC, to get asusal format like others machine..., i have changed in my date format and restarted, thn also getting same dd MMM yyyy Plz any one guide me Thanks & Regards, Member 3879881, please don't forget to vote on the post

        OriginalGriffO D 2 Replies Last reply
        0
        • M Member 3879881

          Hi Griff, Thanks for ur reply, I already created lot of project in the same way..., So i cant go and modify all the project place the date format like (MM/dd/YYY)..., If i change on single place(PC), it will work for all projects..., Thats y asking, where to change the date format in PC, to get asusal format like others machine..., i have changed in my date format and restarted, thn also getting same dd MMM yyyy Plz any one guide me Thanks & Regards, Member 3879881, please don't forget to vote on the post

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Member 3879881 wrote:

          If i change for PC it will work for all projects...,

          ...that are run on that PC. Run your app on someone else's PC and you have no idea what results you will get... Bad idea to rely on PC user setup for specific features!

          Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          M 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Member 3879881 wrote:

            If i change for PC it will work for all projects...,

            ...that are run on that PC. Run your app on someone else's PC and you have no idea what results you will get... Bad idea to rely on PC user setup for specific features!

            Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

            M Offline
            M Offline
            Member 3879881
            wrote on last edited by
            #5

            i have checked the same project with other pc i got my result exactly..., my i/p & o/p goiing fine in other pc..., But in this pc wht i need i didnt get Thanks & Regards, Member 3879881, please don't forget to vote on the post

            D 1 Reply Last reply
            0
            • M Member 3879881

              Hi all other system giving DateTime.Now.ToLongDateString() as Wednesday, July 28, 2010 But my system giving 28 July 2010 wht is the probs, y its giving like tht?, To get asusal like others system dateformat where i should change in my PC? Thanks & Regards, Member 3879881, please don't forget to vote on the post

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              there is a Control Panel often called Regional Settings where each PC user chooses the way dates, times, currencies, etc. are shown by default. For user interaction your app can (and should) choose to use those default settings (that is when you use those specialized methods such as ToLongDateString(), they really mean "take whatever format the user has chosen"). The advantage is the user gets what he prefers, the disadvantage is you cannot predict how wide things will be and the screenshots in your manual may slightly differ from the user's reality. Of course, there also are situations where the format must be fixed, e.g. when writing the date to a file that is going to be used on some other system. That is where you should use ToString() and either pass an explicit formatting string or have your thread's CultureInfo fixed. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              1 Reply Last reply
              0
              • M Member 3879881

                Hi Griff, Thanks for ur reply, I already created lot of project in the same way..., So i cant go and modify all the project place the date format like (MM/dd/YYY)..., If i change on single place(PC), it will work for all projects..., Thats y asking, where to change the date format in PC, to get asusal format like others machine..., i have changed in my date format and restarted, thn also getting same dd MMM yyyy Plz any one guide me Thanks & Regards, Member 3879881, please don't forget to vote on the post

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                This is not the correct way to go. Changing a system setting like that will only screw up the data/time format for EVERYTHING on that PC, not just your app. It's your job to update your code so that is works and plays nice with others. The solution you want is just you being lazy. The correct solultion is to properly write the code so that the users don't need to worry about what your app is doing to other apps on their machines.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                1 Reply Last reply
                0
                • M Member 3879881

                  i have checked the same project with other pc i got my result exactly..., my i/p & o/p goiing fine in other pc..., But in this pc wht i need i didnt get Thanks & Regards, Member 3879881, please don't forget to vote on the post

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  So it proves that your code does not work in all cases. The solution is to update your code so that it does, not change the cases where it doesn't.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  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