c# - Convert week and year to milliseconds -


i need convert, title says, weeks , year milliseconds since 1970. best way in .net? have information of week , year event occurred. week stars on monday. think datetime not answer since can't handle week of year. need method double getmili(int week, int year). anyway

you can put that:

  // let's convert 15th monday in 2014   int mondaysnumber = 15;    datetime source = new datetime(2014, 1, 1);    int delta = 7 + dayofweek.monday - source.dayofweek;    if (delta >= 7)     delta -= 7;    source = source.adddays((mondaysnumber - 1) * 7 + delta);    // finally, convert milliseconds    double result = (source - new datetime(1970, 1, 1)).totalmilliseconds; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -