LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   [kernel Programming] Convert timespec to Datetime (https://www.linuxquestions.org/questions/linux-general-1/%5Bkernel-programming%5D-convert-timespec-to-datetime-852993/)

3logy 12-29-2010 04:44 AM

[kernel Programming] Convert timespec to Datetime
 
Hi people,

i have a little question!!

i'm changing some syscalls functions into kernel 2.6.36.2
So i'm doing this :
Code:

  struct inode * inode;
  struct dentry * dentry;
 
  dentry = path.dentry;
  inode = dentry->d_inode;

  printk( "Date %i \n", inode->i_atime );


But i have a output like this : Date 1293619251

How can i convert inode->i_atime into D:M:Y h:m Format?? or just simply D:M:Y

Thanks

Snark1994 12-30-2010 09:41 AM

That's what is called a timestamp - it's the number of seconds since the midnight on the 1st January 1970.

You can use the ctime function in time.h to convert it to a char* array, which can be manipulated into the format you want :)


All times are GMT -5. The time now is 02:38 AM.