+ 3
how to get the system time
3 Respuestas
+ 4
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
time_t now_time;
now_time = time(NULL);
cout << "The result is counted in seconds!" << endl;
cout << now_time<<endl;
return 0;
}
+ 3
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
public class Program
{
public static void main(String[] args) {
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//可以方便地修
String hehe= dateFormat.format( now );
System.out.println(hehe);
Calendar c = Calendar.getInstance();//可以对每个时间域
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
System.out.println(year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second);
}
}
+ 1
https://code.sololearn.com/csnh7j2lT4mQ/?ref=app
Try this for C++. It will return accurate system time till the last millisecond...