Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 618
  • 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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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