Вопрос по javascript, c#, asp.net, html – Конвертировать странный формат даты в короткий DateTime

1

Error: User Rate Limit Exceeded

Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Andreas Niedermair

Ваш Ответ

5   ответов
1

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededDateTime.ParseExactError: User Rate Limit ExceededDateTime.TryParseExact
1

var d = new Date('Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)');
var curr_day = d.getDate();
var curr_month = ('0'+(d.getMonth()+1)).slice(-2)
var curr_year = d.getFullYear();
var new_date  = curr_year+"-"+curr_month+"-"+curr_day;
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
1

Error: User Rate Limit Exceeded

new Date("Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)")

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
2

Error: User Rate Limit ExceededguaranteedError: User Rate Limit ExceededDateTime.ParseExactError: User Rate Limit Exceeded

var input  = "Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)"
                            .Substring(0, 15);
var format = "ddd MMM dd YYYY";
var date = DateTime.ParseExact(input, format, CultureInfo.InvariantCulture);

// Now date is a DateTime holding the date

var output = date.ToString("yyyy-MM-dd");

// Now output is 2012-04-25
5

Error: User Rate Limit ExceededDateTime.ParseExactError: User Rate Limit ExceededSun Apr 1 2012Error: User Rate Limit Exceededddd MMM d yyyy.

Error: User Rate Limit Exceeded

var str = "Wed Apr 25 2012 00:00:00 GMT+0300 (GTB Daylight Time)";
var index = -1;
for (var i = 0; i < 4; i += 1)
  index = str.IndexOf(' ', index + 1);

Error: User Rate Limit ExceededDateTime:

var date = DateTime
  .ParseExact(str.Substring(0, index), "ddd MMM d yyyy", CultureInfo.InvariantCulture);

Error: User Rate Limit Exceeded

Похожие вопросы