473,561 Members | 3,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing Seconds Into DateTime Representation

good day,

I simply would like to know as to how I can parse seconds to convert them
into equivalent DateTime representation. To be more persice,
I have a DirectShow app written in VB.NET, with a timer in it. Timer ticks
every 1000 milliseconds and then I get the current position of the video
in seconds (the return type here is integer). However seconds in this case
can be greater than 60 in fact all the way up to the maximum amount of
digits Integer type would allow. So what I would like to do is to get
current position, parse it and output it in Hours : Minutes : Seconds
format.

any help would be greatly appreciated.

Nov 21 '05 #1
5 10863
Try setting a TimeSpan variable type :
dim ts as TimeSpan = new TimeSpan(...)
dim Days as integer = ts.Days
dim Hours as integer = ts.Hours
.....

"Nikeman" wrote:
good day,

I simply would like to know as to how I can parse seconds to convert them
into equivalent DateTime representation. To be more persice,
I have a DirectShow app written in VB.NET, with a timer in it. Timer ticks
every 1000 milliseconds and then I get the current position of the video
in seconds (the return type here is integer). However seconds in this case
can be greater than 60 in fact all the way up to the maximum amount of
digits Integer type would allow. So what I would like to do is to get
current position, parse it and output it in Hours : Minutes : Seconds
format.

any help would be greatly appreciated.


Nov 21 '05 #2
Nikeman,

Do you mean
dt as datetime
dt = dt.addseconds(m yseconds * 1000)

http://msdn.microsoft.com/library/de...condstopic.asp

Be aware that in the datetime the ticks are (as in MSDN always written) in
100-nanoseconds. From which value I never understood what it is meant by
that.

I hope this helps

Cor
Nov 21 '05 #3
doh
dt as datetime
dt = dt.addseconds(m yticks \ 1000)
Nov 21 '05 #4
hello everyone.
I tried what you have suggested, and your solution works well.

Thanks very much for your response.
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:#2******** ******@TK2MSFTN GP09.phx.gbl...
Nikeman,

Do you mean
dt as datetime
dt = dt.addseconds(m yseconds * 1000)

http://msdn.microsoft.com/library/de...condstopic.asp
Be aware that in the datetime the ticks are (as in MSDN always written) in
100-nanoseconds. From which value I never understood what it is meant by
that.

I hope this helps

Cor

Nov 21 '05 #5
Nikeman,
I find the "easiest" way is to use TimeSpan.FromSe conds method.

Dim seconds As Integer = 75
Dim elapsed As TimeSpan = TimeSpan.FromSe conds(seconds)
Dim s As String = elapsed.ToStrin g()

TimeSpan also has FromDays, FromHours, FromMillisecond s, FromMinutes, and
FromTicks which are useful for other "durations" . The cool thing about the
TimeSpan.From methods is that they accept Doubles so you can have:

Dim elapsed As TimeSpan = TimeSpan.FromSe conds(1.5)

To create an duration of 1.5 seconds...

Note I will convert the TimeSpan to a DateTime if I need custom Formatting:

Dim seconds As Integer = 75
Dim elapsed As TimeSpan = TimeSpan.FromSe conds(seconds)
Dim value As DateTime = DateTime.MinVal ue.Add(elapsed)
Dim s As String = value.ToString( "mm:ss")

Hope this helps
Jay

"Nikeman" <1@1.com> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl...
good day,

I simply would like to know as to how I can parse seconds to convert them
into equivalent DateTime representation. To be more persice,
I have a DirectShow app written in VB.NET, with a timer in it. Timer ticks
every 1000 milliseconds and then I get the current position of the video
in seconds (the return type here is integer). However seconds in this case
can be greater than 60 in fact all the way up to the maximum amount of
digits Integer type would allow. So what I would like to do is to get
current position, parse it and output it in Hours : Minutes : Seconds
format.

any help would be greatly appreciated.


Nov 21 '05 #6

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

Similar topics

8
9429
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
6
1945
by: Kalle Anke | last post by:
I want to parse a date string, for example '2005-09-23', and since I haven't done this before I would like to ask what is the best way to do it. I've looked around and the dateutil seems to be what most people use, but unfortunately I only get an empty file when I try to download it. I also tried the standard modules and ended up with this ...
3
12785
by: nriesch | last post by:
In the documentation, the "Second" property of class DateTime is a value between 0 and 59. In UTC time, approximately every year of so, a leap second is added at 00:00:00 UTC, so as to account for the irregular rotation of the earth, which is slowing down a little bit. So, a minute can contains 61 seconds ( range 0..60 ). Besides, the NTP...
2
1864
by: Andy | last post by:
Hi guys, I'm writing a program with a feature of accepting user input as command text and parsing it to correct function calls...example: "5 minutes later"/"5 min later"/"5 minute later"/"after 5 minutes"... are being parsed as the same rule so the system will call a later function with minutes=5 as parameter. Of course there are many...
1
2628
by: Karch | last post by:
I am doing some experimenting with serialization (for use with Service Broker) and I am having a problem converting from a .NET DateTime (in the client application) to a SqlDbType.VarBinary (as passed to the stored procedure VARBINARY(MAX)) and then finally back to a valid DATETIME in Sql Server. It seems I have tried everything, but I always...
7
13342
by: TheLostLeaf | last post by:
DateTime tTime = DateTime.Now; ------------------------------------------------------------------------------------------- tTime returns "1:59:00 PM" it never returns seconds. Database field is SQL datetime or smalldatetime.
7
2395
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for a date that was 2 days ago I would like to see "2 days ago" but for something that was 4 days ago I would like to see the actual date. This is often...
3
6322
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I have various times formatted like 00:00:00, so for example, 01:32:05 would be one thirty-two with five milliseconds. I need to convert this into seconds (an integer). First of all, I have been unable to use the mid() function like I did in vb 6.
6
3376
by: i_robot73 | last post by:
I have a file, containing hex values for dates (MMDDYYYY)<status code><??such as: 303530313230303102003035303232303031020030353033323030310200303530343230303102003035303732303031020030353038323030310200 breaking that down: 30353031323030310200 30353032323030310200 30353033323030310200
0
7644
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7568
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8085
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7614
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7928
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5469
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3598
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
892
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.