473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need to format a date!


Hello,
I need to format the current date in C# so it looks like this:
10/4/2006 1:38:53 PM

Can somen tell how i do this?

Many thanks

JJ
Oct 6 '06 #1
5 1294
http://msdn2.microsoft.com/en-us/library/k494fzbf.aspx

"Jens Jensen" <jj@jensen.dkwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
>
Hello,
I need to format the current date in C# so it looks like this:
10/4/2006 1:38:53 PM

Can somen tell how i do this?

Many thanks

JJ


Oct 6 '06 #2
DateTime.Now.ToString(); by default will give you that format.
- or -
DateTime.Now.ToString("G"); for general formatting.

"Jens Jensen" wrote:
>
Hello,
I need to format the current date in C# so it looks like this:
10/4/2006 1:38:53 PM

Can somen tell how i do this?

Many thanks

JJ
Oct 6 '06 #3
Jens,

Is this in your current culture setting, maybe is it better to show it next
time in dd/MM/yyyy hh:mm:ss aa
Or to use a date as 31 december, now we cannot see if you want to use it for
the USA or for the rest of the English speaking cultures in the world.

Cor

"Jens Jensen" <jj@jensen.dkschreef in bericht
news:ui**************@TK2MSFTNGP02.phx.gbl...
>
Hello,
I need to format the current date in C# so it looks like this:
10/4/2006 1:38:53 PM

Can somen tell how i do this?

Many thanks

JJ


Oct 8 '06 #4
Jens,

I see now that you are Danish, in our cultures the am/pm is not used, AFAIK
have you first to change the culture to an English one
(threading.currentthread.currentculture) and that as I wrote in my previous
message depending where the month has to be (in USA or other English
cultures way) or use the ICultureProvider. I thought that Danmark was as
well using a 24 hour clock.

Cor

"Cor Ligthert [MVP]" <no************@planet.nlschreef in bericht
news:e7**************@TK2MSFTNGP05.phx.gbl...
Jens,

Is this in your current culture setting, maybe is it better to show it
next time in dd/MM/yyyy hh:mm:ss aa
Or to use a date as 31 december, now we cannot see if you want to use it
for the USA or for the rest of the English speaking cultures in the world.

Cor

"Jens Jensen" <jj@jensen.dkschreef in bericht
news:ui**************@TK2MSFTNGP02.phx.gbl...
>>
Hello,
I need to format the current date in C# so it looks like this:
10/4/2006 1:38:53 PM

Can somen tell how i do this?

Many thanks

JJ



Oct 8 '06 #5
It doesnt !
Oct 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
3
by: Alicia | last post by:
Hi, I am trying to match two queries and make it into one query. I have only been about to group similar attributes but nothing that looks like the FinalQuery below. If anyone knows of a query...
5
by: Alicia | last post by:
Hello everyone based on the data, I created a union query which produces this. SELECT ,,, 0 As ClosedCount FROM UNION SELECT ,, 0 AS OpenedCount, FROM ORDER BY , ;
2
by: Paul T. Rong | last post by:
I format the ShipDate to Format(, "Short Date") in a query, that is alright, the problem is that no matter I choose ascend or descend, I just cannot make the ShipDate in any order, it is for...
4
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last...
2
by: Bill | last post by:
I have a 200 record database that includes a date/time field, AnnivDate, for a wedding anniversary. AnnivDate has nulls and some incorrect year data. I have been creating the Access database...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
4
xstatic
by: xstatic | last post by:
After searching through the hundreds of links about "Javascript Date Formatting", all I am finding is how to format dates that gives a "current date" result. Here is what I need... I have a...
2
matrekz42
by: matrekz42 | last post by:
Hello friends, I'm trying to run this Dynamic SQL in VB, but I keep getting "Compile Error" Syntax Error, in the "Bolded" area. I'm only trying to change these fields for the second query listed,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.