Jump to content

Welcome! You're currently a Guest.

If you'd like to join in the Discussion, or access additional features in our forums, please sign in with your Evernote Account here. Have an Evernote Account but forgot your password? Reset it! Don't have an account yet? Create One! You'll need to set your Display Name before your first post.

Photo

How to get the date created of a note?


  • Please log in to reply
2 replies to this topic

#1 Raphael Gomes

Raphael Gomes

  • Pip
  • Title: Member
  • Group: Members
  • 6 posts

Posted 06 August 2012 - 09:35 PM

Hello,
I'm trying to get the date created of a note but I'm getting a date totally different from that appears on the Evernote's site like this: Date = {1/2/0001 12:00:00 AM} and in fact the note was created on 8/3/2012, 09:59 AM.
I wonder if I need to add a specific date to arrive the correct date created and what is the date that I have to add?
Or is it necessary to do another procedure to get the correct date?

Here's my code:

noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
noteStoreTransport.CustomHeaders[HttpRequestHeader.UserAgent.ToString()] = USER_AGENT;
noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
noteStore = new NoteStore.Client(noteStoreProtocol);

NoteFilter filter = new NoteFilter();
noteList = noteStore.findNotes(authToken, filter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX);

foreach (Note nt in noteList.Notes)
{
DateTime dtCloud = new DateTime(nt.Created);
}

Attached is the return of date created that I'm saying.

Attached Files



#2 berryboy

berryboy

  • Pip
  • Title: Member
  • Group: Members
  • 42 posts

Posted 06 August 2012 - 11:31 PM

DateTime contructor in C# use timestamp in 100 nano-second.
Evernote timestamp is in millisecond.


DateTime dtCloud = new DateTime(nt.Created * 1000 * 10);

#3 Raphael Gomes

Raphael Gomes

  • Pip
  • Title: Member
  • Group: Members
  • 6 posts

Posted 07 August 2012 - 01:26 PM

Thank you berryboy!
The issue was solved.

My code looks like this:

foreach (Note nt in noteList.Notes)
{
DateTime UnixStartDate = new DateTime(1970, 1, 1);
UnixStartDate = UnixStartDate.AddMilliseconds(nt.Created);
DateTime dtTime = DateTime.FromFileTime(nt.Created * 1000 * 10);
DateTime dtFinalOk = new DateTime(UnixStartDate.Year, UnixStartDate.Month, UnixStartDate.Day, dtTime.Hour, dtTime.Minute, dtTime.Second);
}




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Clip to Evernote