C++-এ বর্তমান তারিখ এবং সময় পাওয়ার উদাহরণ:
উদাহরণ
#include <iostream>
using namespace std;
int main() {
time_t now = time(0);
char *date = ctime(&now);
cout << "The local date and time: " << date << endl;
}
আউটপুট
The local date and time: Wed Oct 3 08:35:24 2018
উপরোক্ত প্রোগ্রামে, বর্তমান তারিখ এবং সময় পাওয়ার কোড main()-এ রয়েছে। এখানে time_t ভেরিয়েবল now-এর রিটার্ন টাইপ। বিল্ট-ইন ফাংশন time() ব্যবহার করা হয়েছে লোকাল করেন্ট টাইম এবং ডেট পাওয়ার জন্য।
time_t now = time(0); char *date = ctime(&now);