Date & DateTime formats

Edwin

New member
Joined
Jun 8, 2005
Messages
2
Programming Experience
1-3
Hi there,My problem is the following: When I assign a custom formatted Date & Time to a Date variable it loses it’s formatting. Ex. 2005-06-07 15:46 [Format(Now(), "yyyy-MM-dd HH:mm")] now when I assign this to a variable of type Date or DateTime this becomes 2005/06/07 03:46:00 The same code work flawlessly on various other machines, thus I presume this is settings related. I know that the Time function in VB.NET reads from the system time, which you set in Regional Settings under the Control Panel. I did try to change the settings but it did not seem to work, unless I'm not setting it up correctly.Any help would be appreciated.Thanx
 
Revised

Edwin said:
Hi there,My problem is the following: When I assign a custom formatted Date & Time to a Date variable it loses it’s formatting. Ex. 2005-06-07 15:46 [Format(Now(), "yyyy-MM-dd HH:mm")] now when I assign this to a variable of type Date or DateTime this becomes 2005/06/07 03:46:00 The same code work flawlessly on various other machines, thus I presume this is settings related. I know that the Time function in VB.NET reads from the system time, which you set in Regional Settings under the Control Panel. I did try to change the settings but it did not seem to work, unless I'm not setting it up correctly.Any help would be appreciated.Thanx



Ok after more investigation I think its best t revise my questions.
Thus:

My problem is the following: I get the current time on the machine by using Now(), but for some weird reason this machine (happens only on this machine) refuses to show/handle the tt part of the time. Thus all the times I get using anything like Now() or even when assigning a formatted time to a variable it does not show AM/PM.



I presume this is a system settings issue, now I looked at the Date/Time & Regional Settings under the Control Panel and yet it is identical to a machine that works perfectly.



My question is thus where does VB.Net get its System Time from and where can I see the settings?

Or alternatively can anyone think of a solution to bypass this problem.

Thanx in advance
Edwin
 
The easiest way I can think of is this...


VB.NET:
dim dtNow as datetime 
 
dtnow=now()
 
console.writeline(dtnow.tostring("yyyy-MM-dd HH:mm"))
The datetime variable stores only the datetime information. Use the .tostring to format the info for output.

HTH

David
 
Back
Top