Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

Timestamp

Just trying to get a timestamp:

new DateTime().ToString()

is that correct?
0
directxBOB
Asked:
directxBOB
  • 2
2 Solutions
 
Ashish PatelCommented:
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
 
directxBOBAuthor Commented:
DateTime().Now

Doesn't appear to exist, what version of ,NET would that be in? I can only use 2.0
0
 
Ashish PatelCommented:
Try using this.
string strDate  = DateTime.Now.ToString();
0
 
Jaime OlivaresSoftware ArchitectCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now