Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3871578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:50:14+00:00 2026-05-19T21:50:14+00:00

Should I use DateTime.Now or DateTime.UtcNow in HttpCookie.Expires and HttpCachePolicy.SetExpires ? Cookies are sending

  • 0

Should I use DateTime.Now or DateTime.UtcNow in HttpCookie.Expires and HttpCachePolicy.SetExpires?

Cookies are sending ‘GMT’ time, but I don’t know what happen if I send DateTime.Now.AddDays(3) if I would be in GMT+5. Same with Expires HTTP header (sec 14.21).

What should I use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T21:50:14+00:00Added an answer on May 19, 2026 at 9:50 pm

    It doesn’t matter in this case.

    Internally, the first thing .SetExpires does is convert your supplied datetime into UTC, before setting it on the cookie.

    Bear in mind, as long as your datetime consumer uses the DateTime class correctly, then the two are the same – it is just that one is “baselined” to UTC and the other isn’t:

    20110701T14:00:00-1:00 (British Summer Time)
    

    and

    20110701T13:00:00+0:00 (UTC)
    

    represent exactly the same datetime, namely 1pm UTC.

    As long as the consumer handles this correctly (which it seems to, having looked in reflector) then it makes no difference.

    If you were taking this and passing it in as a time string, then of course, it may well make a difference, but not in this case.

    You can see the effect with the following code (assuming you are not in UTC yourself – if you are – change your settings to test!). They both output the same datetime, once you’ve asked for it to be converted to UTC.

    WriteDateTime(DateTime.Now);
    WriteDateTime(DateTime.UtcNow);
    
    public static void WriteDateTime(DateTime dateTime)
    {
       Console.WriteLine(dateTime.ToUniversalTime().ToLongTimeString());   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should I use () with datetime.now in defining tables? What code wrong 1 or
I've read I should use money , but in todays fast paced world maybe
I know you should use a StringBuilder when concatenating strings but I was just
I use my epoch as Datetime myepoch=new DateTime(2005,11,11,7,0,0); But I'd like it to be
I am using: datetime.now() to get the current time in an Event app that
Which way use of Factory is better(correct)? IPacket info = PacketFactory.CreatePacketObject(PacketType.Info, currentUser, DateTime.Now, disconnected);
I found this snippet: def timesince(dt, default=just now): now = datetime.utcnow() diff = now
MSDN says that you should use structs when you need lightweight objects. Are there
What GUI should use to run my JUnit tests, and how exactly do I
Why sometimes I should use block and other times &block inside functions that accept

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.