Change datetime format in C# -


hey i'm using randomdate function in c# (it written person here on stackoverflow - thank :) ) anyway returns random date between 2 dates, in format

the code:

public static datetime randomday() {     datetime start = new datetime(2006, 1, 1);     datetime end = new datetime(2013, 12, 31);      random gen = new random();      int range = (end - start).days;     return start.adddays(gen.next(range)); } 

however, returns date in format 2008-10-25, however, want dates represented this:

25.10.2008:00:00.000 

is possible? thanks

call tostring() on date , pass desired format.

var formatted = date.tostring("dd.mm.yyyy:hh:mm.fff"); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -