473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem about get time

Ray
Dear all,
I have some problems about getting the time. For example, it is 18:30
now. How can I get the string "1830"?
I have tried as follow:
String.Concat((Date.Now.ToString("t")).Substring(0 , 2),
(Date.Now.ToString("t")).Substring(2, 2))
However, the result is "6:30"
Please help.
Thanks a lot,
Ray
Nov 21 '05 #1
5 2371
"Ray" <so*****@microsoft.com> schrieb:
I have some problems about getting the time. For example, it is 18:30
now. How can I get the string "1830"?


\\\
MsgBox(DateTime.Now.ToString("hhmm"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
"Ray" <so*****@microsoft.com>'s wild thoughts were released
on Thu, 6 Jan 2005 19:12:50 +0800 bearing the following
fruit:
Dear all,
I have some problems about getting the time. For example, it is 18:30
now. How can I get the string "1830"?
I have tried as follow:
String.Concat((Date.Now.ToString("t")).Substring(0 , 2),
(Date.Now.ToString("t")).Substring(2, 2))
However, the result is "6:30"


Is the date going to be 5 chars long (18:30), or 4 chars
long (6:30)?

Because that will certainly effect the result of
..Substring(2, 2)



Jan Hyde (VB MVP)

--
Candy Bar: Sweet treat (Stan Kegel)

[Abolish the TV Licence - http://www.tvlicensing.biz/]

Nov 21 '05 #3
That's funny Herfried .. Hmmmm ... but it works :)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl...
"Ray" <so*****@microsoft.com> schrieb:
I have some problems about getting the time. For example, it is 18:30
now. How can I get the string "1830"?


\\\
MsgBox(DateTime.Now.ToString("hhmm"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Ray
Dear Herfried,
Thanks for your reply. I have tried your code. However, the result is
"0630". If I want to get "1830", how can I get that?
Thanks,
Ray

"Herfried K. Wagner [MVP]" <hi***************@gmx.at>
???????:O5******************@TK2MSFTNGP12.phx.gbl. ..
"Ray" <so*****@microsoft.com> schrieb:
I have some problems about getting the time. For example, it is 18:30
now. How can I get the string "1830"?


\\\
MsgBox(DateTime.Now.ToString("hhmm"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
"Ray" <so*****@microsoft.com> schrieb:
Thanks for your reply. I have tried your code. However, the result is
"0630". If I want to get "1830", how can I get that?


\\\
MsgBox(#12/12/2002#.ToString("HHmm")
///

..NET Framework Developer's Guide -- Custom DateTime Format Strings
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomdatetimeformatstrings.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
4
by: Gactimus | last post by:
Hey again, I am working my way through the book "C++ Primer Fourth Edition". I am trying to run a program out of the book using Microsoft Visual C++ version 6 and I am given the error message:...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
0
by: Magnus Lundberg | last post by:
Hi, I'm trying to create a XML document looking like this: <?xml version="1.0" encoding="UTF-8"?> <rss> <Header> <FromDate>2006-10-01</FromDate> <ToDate>2007-06-01</ToDate>
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
5
by: jbenner | last post by:
I have opened a PMR for this with IBM, and am not asking for advice from the DB2 DBA community. I am posting this as an FYI that DB2 Health Monitor, even at the latest version of DB2, still can cause...
2
by: violeta123 | last post by:
I am stuck! Please help It might be difficult to explain the problem via email, but I will try. I have a Win 2003 Enterprise server running with the only purpose of a membership web site...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.