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

  • SEARCH
  • Home
  • 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 6581137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:06:52+00:00 2026-05-25T16:06:52+00:00

I have a situation in which I need to set up a re-occuring time

  • 0

I have a situation in which I need to set up a re-occuring time span (for this example, 6 PM – 6 AM is the span of time)

Date is not relevent to this. It is presumed to be a check every single day.

I am having trouble wrapping my head around how to do it because using DateTime.UtcNow does yield me the right time, but it does not yield the right day. However using DateTime.MinValue does not yield the current time. And I was not able to set the Date manually. I have explored the other posts on stack overflow, and I’m just misunderstanding something, I think.. but this is my paltry code at the moment…

var start = DateTime.MinValue.Date.Add(new TimeSpan(18, 0, 0));
            var end = DateTime.MinValue.Date.Add(new TimeSpan(6, 0, 0));
            var timezone = TimeZone.CurrentTimeZone.GetUtcOffset(start);
            var now = DateTime.UtcNow;
            now.Date = DateTime.MinValue;

            // is right now greater than 6pm est?
            Console.WriteLine(start.TimeOfDay < now);
            Console.WriteLine(end < DateTime.UtcNow);
            Console.WriteLine(start.ToShortTimeString());
            Console.WriteLine(DateTime.UtcNow.TimeOfDay);
            Console.WriteLine(timezone.ToString());

            Console.ReadLine();
  • 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-25T16:06:53+00:00Added an answer on May 25, 2026 at 4:06 pm

    I am not sure as what you want to achieve but for a check won’t something like this do for you

    DateTime dt3 = DateTime.UtcNow;
    if(dt3.Hour <= 6 || dt3.Hour >=18)//24 hr format
       MessageBox.Show("6PM - 6AM range");// UTC will have only one time and should get satisfied irrespective of date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation in which I need to set a date and time
I have a situation in which I need to convert a text data into
I have an odd situation in which I need to modify the position of
We have a situation in which we need to update records based on existing
I have a situation in which I need to update some values of a
Hey i have a situation in which i need to pass some variable value
Here's my situation: I have a Data Template set up which contains a ToggleButton
I have a situation where I need to check a couple of things before
I am learning JPA and have one question: In which situations we need more
I have situation in which I read a record from a database. And if

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.