我想将此日期/时间分开“星期二,2017年3月21日15:49:25 +0300”。我希望能够在单独的变量中获得“Tue”,“21”,“Mar”,“2017”。提前谢谢。
答案 0 :(得分:2)
您可以执行以下操作:
<style>
.animate-show,.animate-hide {
-webkit-transition:all linear 1s;
-moz-transition:all linear 1s;
-ms-transition:all linear 1s;
-o-transition:all linear 1s;
transition:all linear 1s;
}
.animate-show.ng-hide-remove,
.animate-hide.ng-hide-add.ng-hide-add-active {
opacity: 0;
display: block !important;
}
.animate-hide.ng-hide-add,
.animate-show.ng-hide-remove.ng-hide-remove-active {
opacity: 1;
display: block !important;
</style>
&#13;
可以找到更多详细信息here
答案 1 :(得分:1)
您可以使用split来获取变量数组,而无需使用任何额外的库。
a="Tue, 21 Mar 2017 15:49:25 +0300"
a=a.replace("," , "")
b=a.split(' ').slice(0,4)
const weekday = b[0]
const dayofmonth = b[1]
const month = b[2]
const year = b[3]
console.log(weekday)
console.log(dayofmonth)
console.log(month)
console.log(year)
<强>输出强>
周二
21个
三月
2017
答案 2 :(得分:1)
dict
tuple
检查程序
comma
答案 3 :(得分:1)
建议使用优秀的moment.js库。
class Program
{
static void Main(string[] args)
{
Person p1 = new Person(1, "abc");
Person p2 = new Person(2, "vbn");
List<Person> list = new List<Person>();
list.Add(p1);
list.Add(p2);
}
public class Person
{
public Person(int id, string name)
{
this.id = id;
this.name = name;
}
public int id { get; set; }
public string name { get; set; }
}
}
答案 4 :(得分:1)
a = 'Tue, 21 Mar 2017 15:49:25 +0300';
splitArray = a.split(' ');
dayOfWeek = splitArray[0].replace(',', '');
dayOfMonth = splitArray[1];
month = splitArray[2];
year = splitArray[3];
time = splitArray[4];
timezoneShift = splitArray[5];
console.log(dayOfWeek);
console.log(dayOfMonth);
console.log(month);
console.log(year);
console.log(time);
console.log(timezoneShift);
&#13;