+ 5

How to print current date and time in c and c# language?

Its possible?

26th Aug 2020, 6:18 PM
Kamal Hussain Mohammadi 🇦🇫
Kamal Hussain Mohammadi 🇦🇫 - avatar
4 Respuestas
+ 5
// C version #include<stdio.h> #include<time.h> int main() { time_t t; time(&t); printf("\nCurrenr time : %s", ctime(&t)); return 0; } https://www.google.com/amp/s/www.geeksforgeeks.org/print-system-time-c-3-different-ways/amp/
26th Aug 2020, 6:23 PM
minirkk
minirkk - avatar
+ 5
#include <stdio.h> #include <string.h> int main() { printf ("%s", __DATE__); return 0; } https://www.sololearn.com/learn/C/2957/
26th Aug 2020, 6:25 PM
minirkk
minirkk - avatar
+ 2
using C# it would be. DateTime aDate = DateTime.Now; Console.WriteLine(aDate.ToString("MM/dd/yyyy")); Console.WriteLine(new DateTime(2021,01,01).ToString()); Have a look this link to find out about all format options. https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1 https://code.sololearn.com/cILKYjJ7urw8
26th Aug 2020, 8:26 PM
sneeze
sneeze - avatar
+ 2
Thanks ❤
1st Sep 2020, 10:24 AM
Kamal Hussain Mohammadi 🇦🇫
Kamal Hussain Mohammadi 🇦🇫 - avatar