2022 Developer Survey is open! Take survey.

Questions tagged [date]

This challenge is intended to be solved by using, manipulating, accepting as input, outputting, or calculating calendar dates or clock times.

Filter by
Sorted by
Tagged with
5 votes
4 answers
572 views

Which Western Zodiac sign is today?

Task: With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice. Rules: This is code golf, the answer with the fewest characters wins. The ...
user avatar
  • 439
12 votes
6 answers
438 views

Implement OADD_MONTHS

Introduction A function that adds months to a date (without overflowing ends of months) is implemented in many languages/packages. In Teradata SQL it's ADD_MONTHS, here are some examples: ...
user avatar
  • 10.9k
14 votes
10 answers
922 views

Which Advent is it?

I know, a bit late. Challenge Your challenge is, given a date, output if it's not an Advent Sunday, or the Advent Sunday of the year. Rules The \$4^\text{th}\$ Advent is determined by the Sunday ...
user avatar
  • 3,605
59 votes
47 answers
8k views

Increment The Time

Every digital clock contains a small creature that has to advance the time every minute [citation needed]. Due to the popularty of digital clocks and the popularity of catching them in the wild, they ...
user avatar
  • 43k
16 votes
14 answers
2k views

When's the Listening Party?

A listening party is an event where a bunch of people get together to listen to some music (like a viewing party, but for music). In the age of the internet you can do Listening Parties online with ...
user avatar
  • 84.9k
11 votes
7 answers
759 views

Days of the Week

Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats: A format similar to ...
user avatar
  • 721
1 vote
0 answers
62 views

Calculate the ISO week of Gregorian Easter [duplicate]

As in this question, your task – should you choose to accept it – is to calculate the date of Easter Sunday according to the Gregorian Computus (as used in the Catholic Church and most others) when ...
user avatar
  • 439
18 votes
31 answers
3k views

Get the day of the year of a given date

Challenge Given two positive integers \$1 \le m \le 12\$ and \$1\le d \le 31\$, representing a month and days into the month, output the amount of days that have passed since January 1st, on a non-...
user avatar
14 votes
6 answers
506 views

When's my weekend finally here?

I like my job, but sometimes it can get a bit tedious and boring. As motivation, I want to know how many hours of work are left before I finally get my two days of weekend and relaxation. I work ...
user avatar
  • 2,861
6 votes
5 answers
260 views

US Tax Due Dates

Introduction In a standard* (e.g. not 2020) tax year, estimated payments are due quarterly according to the schedule outlined in Publication 505. Payment Period Due Date January 1 – March 31 April ...
user avatar
8 votes
5 answers
466 views

When will DST start / end

Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set ...
user avatar
  • 28.6k
12 votes
8 answers
2k views

Generate a British numberplate

Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX where AA is a "DVLA ...
user avatar
  • 18.6k
25 votes
24 answers
2k views

Help me get the day of the week correct

Sometimes, I will think it is one day of the week (e.g Friday) when in reality, it's earlier in the week (e.g Tuesday). Your challenge is to display the number of days my estimates are off by. ...
user avatar
  • 21k
19 votes
3 answers
2k views

Calculate longest Stack Exchange streak

Introduction This challenge is inspired by the Meta Stack Exchange question The longest consecutive days streak; it turns out that the URL ...
user avatar
7 votes
25 answers
531 views

Which th second now in this year

In this challenge you have to find out which nth second it is now in this year, current date and time now. Or in other words, how many seconds have passed since New Year. An example current Date is (...
user avatar
23 votes
37 answers
5k views

What year will it be in n seconds?

You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking ...
user avatar
27 votes
16 answers
4k views

How long till Halley's Comet returns?

Halley's Comet is the only comet that may appear (i.e. become visible to the naked eye on Earth) twice in a human lifetime. The orbital period of Halley's Comet is not constant: it has varied between ...
user avatar
  • 10.3k
7 votes
12 answers
1k views

Output ISO8601 date string from seconds and nanoseconds

One reason why ISO8601 is the best date string format, is that you can simply append as much precision as you like. Given 2 integers representing seconds and nanoseconds that have passed since ...
user avatar
  • 617
15 votes
10 answers
2k views

When does hh:mm = mm.ss?

Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00. Clock: The clock employs ...
user avatar
-1 votes
8 answers
2k views

Make a Ramanujan magic square

Background As you maybe know Ramanujan made this magic square by \$4x4\$ Matrix: This works like all magic squares. But the special thing in this square is that his birthdate is hidden in the first ...
user avatar
  • 3,605
15 votes
4 answers
931 views

Eight days a week

Back in 1965, The Beatles released their hit song 'Eight Days a Week'. In this code-golf challenge we are going to reimagine dates of the 21st century as if there really were eight days a week. Input ...
user avatar
  • 10.3k
8 votes
4 answers
515 views

Find the date that is n days from January 1st 1984

This challenge is a relatively simple concept that I'm surprised has not been done yet. You will be given only an integer as an input. Your task is to find the date that is this number of days from ...
user avatar
  • 3,027
20 votes
35 answers
3k views

Does this month start on a Monday?

June 2020 is a month in which June 1st corresponds to Monday, June 2nd corresponds to Tuesday, ... June 7th corresponds to Sunday. For reference, here's the cal of ...
user avatar
6 votes
3 answers
253 views

Can I trade today?

Back in 2018, there has been introduced new law in Poland to ban trading on sundays, but certain exceptions have been made (listed below). The task today is to determine, can one trade on the sunday ...
user avatar
31 votes
35 answers
5k views

Help, I've mixed my week up!

My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days ...
user avatar
  • 6,657
18 votes
7 answers
2k views

When is the closest Conway's Doomsday?

A quote from MO.SE answer: Although it is well known that Conway was able to quickly calculate the day of the week of any given date, it is less well known that one part of the algorithm is easy to ...
user avatar
  • 62.1k
24 votes
13 answers
5k views

Is this a legal date? - April Fools' edition

Task A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) ...
user avatar
  • 13.8k
22 votes
19 answers
4k views

Even a clock that isn't working gets the time right two or three times a day

Context When I was a little kid, I watched a Disney movie where Goofy told his son "Boy, even a broken clock is right two or three times a day." (see this youtube clip, courtesy of @Arnauld). ...
user avatar
  • 13.8k
17 votes
12 answers
1k views

Day of the week of an ambiguous date

Goal Write a program or function that returns the day of the week for a date, eg. 01/06/2020 -> Mon However, it's unknown if the date is in the format mm/...
user avatar
  • 8,590
9 votes
6 answers
582 views

Pairs of palindromic anagramic dates separated by a palindromic number of days

Definitions: A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when ...
user avatar
32 votes
43 answers
7k views

Is it really time?

A time in the format hhMMss is represented by six numbers in the range 0..9 (e.g.100203 for 3 seconds after 2 minutes after 10am (10:02.03), or ...
user avatar
33 votes
12 answers
3k views

How many countries are in the European Union?

Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease. Your job is to take a date and ...
user avatar
  • 15.2k
7 votes
14 answers
2k views

Print out execution time of program [closed]

Challenge Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution ...
user avatar
12 votes
17 answers
3k views

How many ACUs do I have?

Posted from sandbox The Intro What is an ACU? This challenge is based on the concept of money and since this is an international community, we all use different currencies, so in keeping with our ...
user avatar
  • 6,067
16 votes
6 answers
3k views

What's the Mayan date?

Just over seven years ago, everybody suddenly stopped talking about the Maya people. It is time to rectify that! For clarification, I am talking about the Mesoamerican Long Count Calendar. Your ...
user avatar
10 votes
4 answers
544 views

When is Hannukah?

Input The input will be a year between 1583 and 2239. We just want to know when Hannukah was or will be in that year. This is information used by millions of people every year and put in calendars ...
user avatar
20 votes
11 answers
3k views

Advent calendar

Let's build an advent Calendar for this Christmas! Many Advent calendars for children take the form of a large rectangular card with numbered windows for each day of December starting from 1 ( ...
user avatar
  • 9,426
4 votes
8 answers
400 views

Give me the first day of next month

Simple question! Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format. Example inputs: 2018-05-06 ...
user avatar
  • 1,276
90 votes
52 answers
17k views

Sleep for 1000 years

Some sleep commands implement a delay of an integer number of seconds. However, 232 seconds is only about 100 years. Bug! What if you need a larger delay? Make a ...
user avatar
  • 12k
1 vote
1 answer
265 views

Find all possible dates [closed]

You get a string which contains an integer between 1000 and 99999999 as input. The input string might contain leading zeroes but ...
user avatar
  • 793
26 votes
34 answers
3k views

Days in indexed month

This simple challenge is very similar to this one: How many days in a month? The only difference is you yield the number of days in a month given the index of the month instead of its name. The ...
user avatar
16 votes
10 answers
1k views

Digit Date Range

NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases. Challenge: Inputs: Start date \$s\$; End ...
user avatar
16 votes
5 answers
2k views

What's the current zodiac?

Display the emoji of the eastern zodiac of given time, according to given country. The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a ...
user avatar
  • 4,163
2 votes
0 answers
164 views

Rotated analog clock [closed]

Given: a 12 hour time t in hours and minutes, a rotation r in degrees, return the time shown when an analog clock that is ...
user avatar
  • 6,217
59 votes
13 answers
8k views

Who was president of the USA?

Challenge Write a program that takes as input a day from April 30, 1789 to August 21, 2019 and returns as output who was president of the USA that day. Notes For the list of US presidents, the ...
user avatar
  • 669
6 votes
20 answers
625 views

Get delta of days by current hour and added delta of days

Inputs: current hour: from 0 to 23 (inclusive) delta of hours: [current hour] + ...
user avatar
24 votes
5 answers
600 views

How long's left?

How long's left? Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the ...
user avatar
10 votes
17 answers
1k views

Tesco's Burger Relish Best Before End date number

Given a date between 2010-01-01 and 2099-12-31 as three integers (please state your order if not [year,month,day]), answer with Tesco's corresponding five-digit ...
user avatar
  • 27.1k
26 votes
19 answers
3k views

Analog is Obtuse!

An analog clock has 2 hands*: Hour and minute. These hands circle the clock's face as time goes by. Each full rotation of the minute hand results in 1/12th of a rotation of the hour hand. 2 full ...
user avatar
  • 11.1k
-1 votes
14 answers
592 views

FizzBuzz but time-based

Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print ...
user avatar

1
2 3 4 5 6