date javas code example
Example 1: java date time
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
public class CurrentDateTimeExample1 {
public static void main(String[] args) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
System.out.println(dtf.format(now));
}
}
Example 2: dates in javascript
new Date();
// Sat Jan 16 2021 22:08:57 GMT-0500 (Eastern Standard Time)
Date.now();
// 1610852869057 -> Seconds passed since Jan 1,1970
// Set the date
new Date(year, month, day hours, minutes, seconds, milliseconds)