Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

System Date & Time

Posted on 1999-08-18
3
Medium Priority
?
241 Views
Last Modified: 2010-04-15
How do I obtain the system date n time?  Every pc's system date n time is set to a different format, for example...
1999-05-06 or 06-05-1999 or 06/05/1999.  What's the command to use to get the format of the system date so that I can let the user know what type of date format should be entered .  Thanks.
0
Comment
Question by:pearl1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:curri
ID: 1264579
You don't really need to :)
There are system calls (time()  in C?) that give you a number independent of format (I think it was number of seconds since 1980 in a PC); and then you can transform it to whatever format you want it (I'm sure they are functions for this in C too, just can't remember their names, check documentation for time.h or sys/time.h).

If you really want the format the system is using, you may also try asking in a OS specific forum (I assume you are using some version of Windows, since you talk about a PC as it that's enhough info ... :)


0
 
LVL 11

Accepted Solution

by:
alexo earned 80 total points
ID: 1264580
For a Win32 platform use GetSystemTime() or GetLocalTime().  You can retrieve strings for any given time or date in a format that is appropriate for the current locale by using the GetTimeFormat() and GetDateFormat() functions.  Also see EnumDateFormats() and EnumTimeFormats().

In plain C gives you use gmtime() or localtime() to query the time, asctime() to convert it to a (system defined) string or strftime() which lets you control the format.

Please ask Windows-specific questions in the Windows programming area.
Please ask MFC-specific questions in the MFC area.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6820353
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects that and the expert will now receive these points, all verified.
Moondancer
Moderator @ Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question