Solved

The local computer time including seconds

Posted on 2006-10-19
4
151 Views
Last Modified: 2010-04-23
Hi,

I need to create a unique filename based on the exact time ie;

03:13

to this...

031334

This is for a unique filename.
0
Comment
Question by:nickmarshall
[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
4 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17764525
Could try something like :

        Dim FileName As String
        Dim RND As New System.Random

        FileName = Now.Hour.ToString.PadLeft(2, "0"c) & Now.Minute.ToString.PadLeft(2, "0"c) & Now.Second.ToString.PadLeft(2, "0"c) & RND.Next(1, 1000)

        Console.WriteLine(FileName)

this also adds a random number at the end ..
0
 
LVL 3

Expert Comment

by:herreruud
ID: 17764616
Dim sFolderPath As String = "C:\Test"
Dim sFileName As String = String.Format("{0}\{1}.extention",sFolderPath,now.Ticks.ToString)
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17764975
Hi,

thanks for this.  Would I also be able to add in front the date in numerices ie; 01112006
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 50 total points
ID: 17765096
Try:

Dim FileName As String = Now.ToString("ddMMyyyy hhmmss")

(You can remove the space in the ToString parameter if you dont want to seperate the date and time...)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

630 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