locked
DateTime.Now issue RRS feed

  • Question

  • User-131805334 posted

    Hi All,

     I have used DateTime.Now in my asp.net program but the system keeps returning me the date of 20180701. I have checked the server date and time format and is correctly reflecting as 07/10/2018 and Region and Language:English(United States),Date format:M/d/yyyy.

    Why is this so ? Will using DateTime.UtcNow has the same issue?

    Thank You.

    Tuesday, July 10, 2018 9:13 AM

All replies

  • User-369506445 posted

    hi

    it possible you have set a format for the date below like :

    DateTime.Now.ToString("yyyyMMdd")

    result

    20180710

    please, <g class="gr_ gr_140 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="140" data-gr-id="140">First</g> check it

    Tuesday, July 10, 2018 9:25 AM
  • User-131805334 posted

    Hi,

      I did not set the format for the date. I am using DateTime.Now. I have migrated the same codes to the Testing and Production environment. The testing environment is giving me the correct date as 20180710 but not the Production. I have checked that the server 's date/time format is correct too.

    Tuesday, July 10, 2018 10:00 AM
  • User-369506445 posted

    it depended to your code, please more describe for <g class="gr_ gr_74 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="74" data-gr-id="74">solve</g> it, out your code here

    Tuesday, July 10, 2018 10:09 AM
  • User283571144 posted

    Hi ros.work88,

    As far as I know, the datetime.now is set to current date and time on this computer. 

    Its value is your computer's system time.

    I suggest you could firstly modify the date and time on the computer from control panel's date, then I suggest you could try to get the datetime.now again.

    This will make the datetime.now's value changed.

    Best Regards,

    Brando

    Wednesday, July 11, 2018 7:05 AM