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

x
?
Solved

The local computer time including seconds

Posted on 2006-10-19
4
Medium Priority
?
158 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 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

704 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