-2

I am working on a project and I want every day has an integer value so when the user click on a range of days they can be stored in an Array.If anyone could help me on this?

z.gh
  • 1
  • 2
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – sujith karivelil Apr 26 '17 at 05:35
  • Welcome! put your code example that what you try for. and visit link **[How to Ask](http://stackoverflow.com/help/mcve)** – Zaheer Ul Hassan Apr 26 '17 at 05:42
  • You will get more answers/ideas if you show(the code or pseudo code) how you will use those integers, how you get selected days. If you don't know from where to start, then you didn't investigate this issue before writing a question. Currently your question is just simple guess game for everybody. – Fabio Apr 26 '17 at 05:45

2 Answers2

0

Just convert the DateTime to Unix Timestamp and save it your array.

public static double DateTimeToUnixTimestamp(DateTime dateTime)
{
    return (TimeZoneInfo.ConvertTimeToUtc(dateTime) - 
           new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds;
}

How to convert a Unix timestamp to DateTime and vice versa?

WhileTrueSleep
  • 1,524
  • 1
  • 19
  • 32
  • Good attempt to guess what OP wants, but afraid OP need integer to be "associated" with the date, so those integers can be retrieved from selected days. – Fabio Apr 26 '17 at 05:40
  • hmm I dont undrestand thi part of the cod. new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)).TotalSeconds; – z.gh Apr 26 '17 at 16:06
0

Why don't you use a DateTime Array?

DrNachtschatten
  • 392
  • 5
  • 11
  • I don,t know how to use it here? I thaought that is for the current time and date not what we select on calendar – z.gh Apr 26 '17 at 11:40
  • A DateTime is a representation of any given time. What you mean is `DateTime.Now`. For Details of using DateTime see [MSDN](https://msdn.microsoft.com/library/system.datetime(v=vs.110).aspx). – DrNachtschatten Apr 26 '17 at 12:25
  • Thanks for your help I will try to use that and share the result. – z.gh Apr 26 '17 at 16:05