Recent

Author Topic: Get TimeStamp [Beginner question]  (Read 12796 times)

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Get TimeStamp [Beginner question]
« on: May 02, 2010, 11:21:35 am »
Hi Programmers!

How can I get the UNIX timestamp of the current time?

This doesn't work:

Code: [Select]
Writeln ('UNIX TimeStamp is : ',Now);
Relative

motaz

  • Sr. Member
  • ****
  • Posts: 495
    • http://code.sd
Re: Get TimeStamp [Beginner question]
« Reply #1 on: May 02, 2010, 11:50:38 am »
Did you mean display computer time?

Code: [Select]
Writeln ('UNIX TimeStamp is : ', DateTimeToStr(Now));

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Re: Get TimeStamp [Beginner question]
« Reply #2 on: May 02, 2010, 11:53:05 am »
No, not.

I would like to get this output result:

Code: [Select]
UNIX TimeStamp is : 1272809100

motaz

  • Sr. Member
  • ****
  • Posts: 495
    • http://code.sd
Re: Get TimeStamp [Beginner question]
« Reply #3 on: May 02, 2010, 12:09:58 pm »
what is it representing?
is it seconds from 1970 or something like that?

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Re: Get TimeStamp [Beginner question]
« Reply #4 on: May 02, 2010, 12:10:59 pm »
Yes, it is.

Here is an example UNIX time converter site: OnlineConversion.com - Unix Time Conversion

motaz

  • Sr. Member
  • ****
  • Posts: 495
    • http://code.sd
Re: Get TimeStamp [Beginner question]
« Reply #5 on: May 02, 2010, 12:15:44 pm »
Add SysUtils to uses clause, and then write this code:

Code: [Select]
  Writeln('UNIX TimeStamp is : ', Trunc((Now - EncodeDate(1970, 1 ,1)) * 24 * 60 * 60));

You may find a better solution

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Re: Get TimeStamp [Beginner question]
« Reply #6 on: May 02, 2010, 12:50:27 pm »
Thank you Motaz!

It's working!

 

TinyPortal © 2005-2018