INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Code to display current date and time in UTC format?

Code to display current date and time in UTC format?

(OP)
I need to obtain the current date and time in UTC (ISO 8601 extended) format to save it to a file like this:

"2013-02-02T11:25:17Z"

Would like the complete code (I do apologize for this, but my knowledge of this kind of programming is virtually zero blush ), e.g. a Button1OnClick event.

Thank you in advance.

RE: Code to display current date and time in UTC format?

Something like this:

var
myDate : TDateTime;

begin
myDate := StrToDateTime('02/06/2013 08:15');
ShowMessage('Date & Time = ' +DateTimeToStr(myDate));
end;

RE: Code to display current date and time in UTC format?

Sorry, missed the formatting blush

CODE

var
  myDate : TDateTime;
  
begin
  myDate := StrToDateTime('02/06/2013 08:15');
  ShowMessage('Date & Time = ' +DateTimeToStr(myDate));
end; 

RE: Code to display current date and time in UTC format?

(OP)
Thank you.

However, I need to display it like this:

2013-02-02T11:25:17Z

RE: Code to display current date and time in UTC format?

(OP)
Thank you both!

RE: Code to display current date and time in UTC format?

One thing to watch out for: 'Now' is local time and not your time converted to UTC. You have to be mindful of time zones and daylight savings time shifts.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close