Number /
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
yyyy/mm/dd hh24:mi:ss)結果のサンプルは、「2004年2月10日 午後3時30分15秒」時点のもの
$ ./test 現在の日時 : 2004/02/10 15:30:45 $
#include <stdio.h>
#include <time.h>
int main()
{
time_t t;
struct tm * lt;
/* 現在時刻を得る */
time(&t);
/* ローカル時間構造体に変換 */
lt = localtime(&t);
printf("%04d/%02d/%02d %02d:%02d:%02d\n",
lt->tm_year + 1900,
lt->tm_mon + 1,
lt->tm_mday,
lt->tm_hour,
lt->tm_min,
lt->tm_sec
);
return 0;
}
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
int main()
{
time_t t;
struct tm * lt;
// 現在時刻を得る
time(&t);
// ローカル時間構造体に変換
lt = localtime(&t);
cout << setfill('0')
<< setw(4) << lt->tm_year + 1900 << "/"
<< setw(2) << lt->tm_mon + 1 << "/"
<< setw(2) << lt->tm_mday << " "
<< setw(2) << lt->tm_hour << ":"
<< setw(2) << lt->tm_min << ":"
<< setw(2) << lt->tm_sec
<< endl;
return 0;
}
import java.util.*; // Date
import java.text.*; // SimpleDateFormat
class Main {
public static void main(String[] args) {
// 現在時刻を得る
Date d = new Date();
// フォーマット変換
SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
System.out.println(f.format(d));
}
}
# 現在時刻の構造体を取得 my @time = localtime; $time[4] += 1; $time[5] += 1900; printf"%04d/%02d/%02d %02d:%02d:%02d\n", reverse @time[0..5];
# 現在時刻取得 -> 表示
puts Time.now.strftime("%Y/%m/%d %H:%M:%S")
最終更新日 : 2004.08.23

Number /
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
copyright 2000-2005
ARGIUS project