How-to articles, tricks, and solutions about DATE

Calculate age based on date of birth

Here is some sample PHP code that calculates a person's age based on their date of birth:

Calendar date to yyyy-MM-dd format in java

To format a Calendar date in the yyyy-MM-dd format in Java, you can use the SimpleDateFormat class.

Checking if date is weekend PHP

To check if a date is a weekend in PHP, you can use the date function to get the day of the week for a given date and then check if it is either 0 (Sunday) or 6 (Saturday).

Convert date to datetime in Python

You can convert a date to datetime in Python using the datetime module.

Convert java.util.Date to String

To convert a java.util.Date object to a String, you can use the format method of the SimpleDateFormat class from the java.text package. The SimpleDateFormat class provides a convenient way to convert a Date object to a String based on a specified format.

Converting ISO 8601-compliant String to java.util.Date

To convert an ISO 8601-compliant string to a java.util.Date object, you can use the java.text.SimpleDateFormat class and specify the "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" format, which is the ISO 8601 format for dates with a time and time zone.

Date format Mapping to JSON Jackson

You can use the @JsonFormat annotation to specify the format of date fields in a JSON payload when serializing or deserializing using Jackson.

Difference between 2 dates in seconds

In PHP, you can use the built-in function strtotime() to convert a date string to a Unix timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).

Elegant way to get the count of months between two dates?

There are multiple ways to get the count of months between two dates in PHP, but one elegant way is to use the DateTime class and the diff() method.

Get current date, given a timezone in PHP?

To get the current date and time in a specific timezone in PHP, you can use the date_default_timezone_set function to set the timezone and then use the date function to get the current date and time.

Get integer value of the current year in Java

To get the integer value of the current year in Java, you can use the Calendar class and the get method.

How can I get the current date and time in UTC or GMT in Java?

To get the current date and time in UTC or GMT in Java, you can use the Instant class from the java.time package. The Instant class represents a single point in time in the ISO-8601 calendar system, with a resolution of nanoseconds.

How can I increment a date by one day in Java?

To increment a date by one day in Java, you can use the plusDays() method of the java.time.LocalDate class from the java.time package.

How do I get a Date without time in Java?

To get a java.util.Date object with the time set to 00:00:00 (midnight), you can use the toInstant() method to convert a LocalDate object to an Instant, and then use the atZone() method to convert the Instant to a ZonedDateTime object, and finally use the

How do I get the day of week given a date?

You can use the datetime module in Python to get the day of the week for a given date.

How Get the Current Year in JavaScript

Read this tutorial and learn about the simplest and fastest method of getting the current year a four-digit number using the Date object in JavaScript.

How to Add Days to JavaScript Date

Read the tutorial and learn a simple method of adding days to JavaScript date with two inbuilt functions used for setting and getting the day of the month.

How to calculate number of days between two given dates

To calculate the number of days between two dates, you can use the timedelta class from the datetime module.

How to Calculate the Difference between Two Dates Using PHP?

On this page, you have an opportunity to get comprehensive information on how to calculate the difference between two dates with the help of PHP.

How to change date format in a Java string?

To change the date format in a Java string, you can use the SimpleDateFormat class.

How to check if a date is in a given range?

In PHP, you can use the DateTime class to check if a date is within a given range.

How to Clone a Date Object in JavaScript

Read the tutorial and learn two useful methods that are used to clone the Date object in JavaScript. Get the current date and the cloned one right away.

How to compare dates in Java?

You can compare dates in Java by using the compareTo() method of the java.util.Date class. This method compares the date object on which it is called with the date object passed as an argument to the method

How to Convert a Date Format in PHP

On this page, we are going to help you figure out the main ways of converting date formats in PHP.

How to Convert a Unix Timestamp to Time in JavaScript

Read the tutorial and find how you can convert the UNIX timestamp to time in JavaScript to make the Unix format date-time value in a user-readable format.

1 2 3