How-to articles, tricks, and solutions about DATETIME

How to get milliseconds from LocalDateTime in Java 8

To get the milliseconds from a LocalDateTime object in Java 8, you can use the toInstant method and the toEpochMilli method.

How to get the current date/time in Java

To get the current date and time in Java, you can use the <code>java.time</code> package introduced in Java 8.

How to Get the Current Year with PHP

On this page, you will get solutions to a common issue in PHP: how to get the current year.

How to get the first day of the current year?

In PHP, you can use the mktime function to get the Unix timestamp of the first day of the current year, then use the date function to format it as a date string.

How to print a date in a regular format?

In Python, you can use the datetime module to work with dates and times.

How to separate DATE and TIME from DATETIME in MySQL?

You can use the DATE() and TIME() functions to extract the date and time parts of a DATETIME value in MySQL.

How to subtract a day from a date?

You can use the datetime module in Python to subtract a day from a date.

How to subtract X day from a Date object in Java?

To subtract a certain number of days from a Date object in Java, you can use the Calendar class.

Java 8: Difference between two LocalDateTime in multiple units

To find the difference between two LocalDateTime objects in multiple units, you can use the Duration class.

Laravel Carbon: how to change timezone without changing the hour?

In Laravel, you can use the setTimezone method on a Carbon instance to change the timezone without changing the hour.

1 2