- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ctime() Function in C/C++
The C library function char *ctime(const time_t *timer) returns a string representing the localtime based on the argument timer.
The returned string has the following format − Www Mmm dd hh:mm:ss yyyy, where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year.
The syntax is like below −
char *ctime(const time_t *timer)
This function takes the pointer to a time_t, which is containing the calendar time. It returns a string containing date, time info in human readable format.
Example
#include <stdio.h> #include <time.h> int main () { time_t curtime; time(&curtime); printf("Current time = %s", ctime(&curtime)); return(0); }
Output
Current time = Thu May 23 17:18:43 2019
Advertisements