Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-29-2010, 05:44 AM   #1
LQ Newbie
Registered: Dec 2010
Posts: 10

Rep: Reputation: 0
[kernel Programming] Convert timespec to Datetime

Hi people,

i have a little question!!

i'm changing some syscalls functions into kernel
So i'm doing this :
  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

Old 12-30-2010, 10:41 AM   #2
Senior Member
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mktime adds hour unless extra timespec pointers declared halestorm914 Programming 3 12-03-2010 12:34 PM
[SOLVED] Simple Linux script to convert datetime format to UTC format shayno90 Linux - Newbie 10 10-09-2009 09:19 AM
Convert timeval to timespec ranthal Linux - Kernel 3 07-06-2009 07:31 PM
Using struct timespec from time.h pd9 Linux - Kernel 0 07-26-2008 05:56 PM
Convert Time String to DATETIME field Centinul Programming 2 09-25-2006 08:20 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration