DateTime problem for aspx page

Hi,

I am trying to get the current date and the current time as two *separate* entities.

I have tried

DateTime d = DateTime.Now;                      
Response.Write(d.Date);

But this still insists on giving the time (00.00.00) after the date (shown correctly).

How can I get the date and time alone ?

Cheers in advance.
LVL 19
mrwad99Asked:
Who is Participating?
 
smeggheadConnect With a Mentor Commented:
change your locale settings to use this format (international setting in control panel) or use a specific format string

string strDate=d.ToString("dd/MM/yyyy");
0
 
naveenkohliCommented:
Try this..

string strDate = d.ToString("d",DateTimeFormatInfo.InvariantInfo);
string strtime = d.ToString("T",DateTimeFormatInfo.InvariantInfo);
0
 
smeggheadCommented:
or...

string strDate=d.ToShortDateString();
string strTime=d.ToShortTimeString();
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mrwad99Author Commented:
OK they both work but give the date in MM/DD/YY format; how can I get it in DD/MM/YY format ?

Cheers.
0
 
mrwad99Author Commented:
Brilliant.  Thanks a lot.

Also thanks to naveenkohli for the an equally good first answer.
0
 
smeggheadCommented:
0
All Courses

From novice to tech pro — start learning today.