Solved

Timestamp

Posted on 2007-11-14
4
584 Views
Last Modified: 2012-05-05
Just trying to get a timestamp:

new DateTime().ToString()

is that correct?
0
Comment
Question by:directxBOB
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20279036
string strDate  = DateTime().Now.ToString();

and for both date and time as different do this

string strDate = DateTime.Now.ToShortDateString();
string strTime = DateTime.Now.ToShortTimeString();
0
 

Author Comment

by:directxBOB
ID: 20279065
DateTime().Now

Doesn't appear to exist, what version of ,NET would that be in? I can only use 2.0
0
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 250 total points
ID: 20279092
Try using this.
string strDate  = DateTime.Now.ToString();
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 250 total points
ID: 20279881
Now is a property, not a method, like asvforce stated.

if you want the timestamp as a unique 64-bit value, you can use:
    long ts = DateTime.Now.ToBinary();
or as a string:
   string ts = DateTime.Now.ToBinary().ToString();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now