+ 1
Find Date and Time using code ?
any language as you want. Get current date and time and print it
5 ответов
+ 8
🐍
import datetime
print(datetime.datetime.now())
+ 3
/*add this to the main method in Java and run*/
System.out.println(new Date());
+ 3
// Try this instead:
/* WILL NOT PRINT DATE ACCORDING TO YOUR TIME ZONE, AS THE CODE ITSELF IS NOT EXECUTING ON YOUR DEVICE, BUT ON SOLOLEARN SERVER - THATS IF YOU RUN IT ON SOLOLEARN*/
import java.text.*;
public class Date
{
public static void main(String[] args) {
SimpleDateFormat f = new SimpleDateFormat ("h:m a E,MMMM Y");
System.out.println(f.format(new java.util.Date()));
}
}
+ 1
i didnt got a proper date
https://code.sololearn.com/cO9lTqV2mRhs/?ref=app
+ 1
in Ruby :
puts Time.now.strftime("%d/%m/%Y %H:%M")