# What is 10 Months from Today [Code in 5 Programming Languages]

## Introduction

In this tutorial, we will learn about What is 10 months from today by looking at the code in 5 different Programming languages. In programming world, date and time calculation is fundamental operation often encountered in various applications. In today’s world where technology is emerging way beyond our expectation, it has become crucial to have the understanding on how date and time manipulation is done. This operation is quite often used in tasks like scheduling, data analysis and manipulating time-sensitive operations. So let us understand how date and time manipulation works in programming world.

## What is 10 Months from Today [Code in 5 Programming Languages]

When someone asks us what will be the date two days later or 2 years later, we either use calendar  to find out or maybe look for some online tool available which will let is know  within no time. But have you ever thought of finding it in more interesting way ?. Well, let’s do it now. We will write the code to find the date 10 months from today in 5 different programming languages.

### 1. Bash Script

In bash script, we use `date` command to find the current date. We have calculated the current date in format ‘YYYY-MM-DD’. We have used `date -d "+10 months"` to calculate the date 10 months from now. We have printed the output on the console using `echo`  command.

```#!/bin/bash

current_date=\$(date +%Y-%m-%d)
new_date=\$(date -d "\$current_date + 10 months" +%Y-%m-%d)
echo "10 months from today is: \$new_date"```

OUTPUT

`10 months from today: 2024-08-21`

### 2. Python Program

In Python, we use datetime module to perform operations related to date and time. We can use datetime.now() function to find out what will be the date after 10 months from today. In the below example, we have imported datetime and timedelta function from datetime module. We have stored the current date in variable called ‘current_date’. We find the 10 months later by adding 10 times 30 days assuming each month has 30 days.

```from datetime import datetime, timedelta

current_date = datetime.now()

# Consider an average of 30 days per month
date_after_ten_months = current_date + timedelta(days=10*30)
print("10 months from today is:", date_after_ten_months.strftime('%Y-%m-%d'))```
OUTPUT
`10 months from today is: 2024-08-16`

### 3. Golang Program

In golang, there is a package calledtime which can be used to perform date and time related operations. In the below example, we calculate the current date using time.Now() function and store in a variable called currentTime. Next, we use AddDate() function to calculate 10 months later from today. We print the output using fmt.Println() function.

```package main

import (
"fmt"
"time"
)

func main() {

currentTime := time.Now()
fmt.Println("10 months from today is:", newTime.Format("2006-01-02"))
}```
OUTPUT
`10 months from today is: 2024-08-21`

### 4. C Program

In C programming language, we can use header file called time.h. In the below example, we calculate the current date using ‘time(NULL)‘ function. We have used ‘localtime()‘ to get the local time struct. Next, we have added 10 months to the month value and adjust the date if necessary. At the end, we print the output in the format ‘YYYY-MM-DD’.

```#include <stdio.h>
#include <time.h>

int main() {
time_t currentTime = time(NULL);
struct tm *localTime = localtime(&currentTime);
localTime->tm_mon += 10;
mktime(localTime);
printf("10 months from today is: %d-%02d-%02d\n", localTime->tm_year + 1900, localTime->tm_mon + 1, localTime->tm_mday);
return 0;
}```

OUTPUT

`10 months from today is: 2024-08-21`

### 5. Java Program

In Java, we can use LocalDate module to perform date and time operations. We have used LocalDate.now() function to calculate the current date and stored in variable called ‘currentDate’. Next, we add 10 months using ‘plusMonths()‘ method. We have printed the output using System.out.println() function.

```import java.time.LocalDate;

public class Main {
public static void main(String[] args) {
LocalDate currentDate = LocalDate.now();
LocalDate newDate = currentDate.plusMonths(10);
System.out.println("10 months from today is: " + newDate);
}
}```

OUTPUT

`10 months from today is: 2024-08-21`

## Summary

We have learnt about date rand time manipulation technique in different programming languages.