Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current date and time

I want to get the current date and time.

For example:

2012/11/13 06:30:38 

What I have tried:

Dim d As System.DateTime MsgBox(d.Year) 'Return 1 
like image 980
Nh123 Avatar asked Nov 13 '12 04:11

Nh123


People also ask

How do I display current date and time?

Excel also contains two functions that will display a current date and time. The TODAY function will display the current date, and the NOW function will display the current date and time. Unlike the date and time stamps above, these functions will continue to update each time the worksheet is opened or changed.

How do I get the current date and time in Python?

Datetime module comes built into Python, so there is no need to install it externally. To get both current date and time datetime. now() function of DateTime module is used. This function returns the current local date and time.

How do I get the current date and time in powershell?

Get-Date uses the UFormat parameter with format specifiers to display the current system date and time. The format specifier %Z represents the UTC offset of -07. The $Time variable stores the current system date and time. $Time uses the ToUniversalTime() method to convert the time based on the computer's UTC offset.


2 Answers

use DateTime.Now

try this:

DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") 
like image 98
famf Avatar answered Oct 06 '22 20:10

famf


Try this one:

System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") 
like image 42
pao Avatar answered Oct 06 '22 18:10

pao