Getting the date | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Getting the date

why does the function of getting the month give you an answer one month smaller.?example I wanted to get December which is the 12th month but instead it gave me an integer of 11.

12th Dec 2016, 10:42 AM
Walter Musara
Walter Musara - avatar
6 Answers
+ 3
Indeed, the first month it's 0. A quick solution it's add +1 to the result.
12th Dec 2016, 11:02 AM
Nahuel
Nahuel - avatar
+ 1
Can you provide the code you used? I suspect you're using an array.
12th Dec 2016, 10:56 AM
Muhammad Kamal
Muhammad Kamal - avatar
+ 1
How do you get number? Normally date() provides month as a name. You can use .format() to alter the output.
12th Dec 2016, 12:20 PM
Andrey Kitsa
Andrey Kitsa - avatar
+ 1
Search for the program:Christmas countdown to see the code Muhammad Kamal
12th Dec 2016, 1:21 PM
Walter Musara
Walter Musara - avatar
0
ok
12th Dec 2016, 12:46 PM
Dayne
Dayne - avatar
0
Check code playground page, first example is "what a date now?". So very easy.
12th Dec 2016, 3:23 PM
IlyaBelgradsky
IlyaBelgradsky - avatar