Timestamp is commonly used in C# applications. It’s important to clarify that it’s not an existing function and it’s not necessary to add “using” lines at the top. It’s just a feature that requires the usage of a DateTime value and then call the “ToString()” function with a string parameter specifying the values we want for return.
For example, the most complete value to get for a timestamp is the following:
String timeStamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");
MessageBox.Show(timeStamp);
The result is:
So, if you just want a part of the Timestamp, just remove some characters from the string parameter:
String timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss");
MessageBox.Show(timeStamp);
The result is:
There’re no dependencies between values of a timestamp. You can select which values to retrieve:
String timeStamp = DateTime.Now.ToString("yyyyddss");
MessageBox.Show(timeStamp);
The result is:
Finally, let’s clarify that additional characters can be added to the string parameter:
String timeStamp = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
MessageBox.Show(timeStamp);
The result is:
No hay comentarios.:
Publicar un comentario