private static DateTime targetTime = DateTime.Now;
private static DateTime now = DateTime.Now;
private static int nextDay = 0;
public static void Main()
int currentHour = now.Hour;
string hourOfDay = "1,8,13,22";
string[] arr = hourOfDay.Split(',');
for(int i = 0;i<arr.Length;i++){
int element = Int32.Parse(arr[i]);
if(element > currentHour){
Console.WriteLine(DateTime.Now);
Console.WriteLine("Next time ["+nextTime+"] = "+arr[nextTime]);
if(nextTime < arr.Length){
int hour = Int32.Parse(arr[nextTime]);
targetTime = DateTime.Now.AddDays(nextDay).Date.AddHours(hour);
if(targetTime > DateTime.Now){
string min = targetTime.Subtract(DateTime.Now).TotalMinutes.ToString();
Console.WriteLine("Countdown time in munutes: " + min);
if (targetTime == DateTime.Now)
if(nextTime == arr.Length)