我想将IST时区格式的日期字符串转换为GMT时区的日期。
日期字符串:
function q41895153_ode45()
time_range = 1990:0.1:2015;
time_hist = 1990:5:2015;
b=zeros(1,6); %75-2000 per 5 years
b(1)=0.0358;
b(2)=0.0339;
b(3)=0.0311;
b(4)=0.0275;
b(5)=0.0249;
b(6)=0.0249;
m=zeros(1,6); %90-2015 per 5 years
m(1)=0.008;
m(2)=0.0031;
m(3)=0.0137;
m(4)=0.0147;
m(5)=0.0125;
m(6)=0.0125;
l=zeros(1,6); %90-2015 per 5 years
%{
l(1)=0.015;
l(2)=0.031;
l(3)=0.026;
l(4)=0.015;
l(5)=0.014;
l(6)=0.014;
%}
l(1)=0.001;
l(2)=0.001;
l(3)=0.001;
l(4)=0.001;
l(5)=0.001;
l(6)=0.001;
u=zeros(1,6); %90-2015 per 5 years
u(1)=0.04;
u(2)=0.02;
u(3)=0.038;
u(4)=0.05;
u(5)=0.035;
u(6)=0.035;
S0=18442;
I0=186; %1990
P=zeros(1,6); %15 years before S
P(1)=12788;
P(2)=14731;
P(3)=16968;
P(4)=19696;
P(5)=22893;
P(6)=22893;
[time, xy] = ode45(@test_func,time_range,[S0 I0],odeset(),time_hist,P,b,m,l,u);
S = xy(:,1)
I = xy(:,2)
N = S + I
plot(time,xy);
end
function rhs = test_func(t,xx,time_hist,P,b,m,l,u)
S = xx(1);
I = xx(2);
% Interpolate to find b(t), m(t), l(t), u(t), P(t)
bt = interp1(time_hist,b,t);
mt = interp1(time_hist,m,t);
lt = interp1(time_hist,l,t);
ut = interp1(time_hist,u,t);
Pt = interp1(time_hist,P,t);
Sdot=bt*Pt-mt*S-lt*S*I;
Idot=lt*S*I-(mt+ut)*I;
rhs = [Sdot; Idot];
end
预期产出:
2017-01-29 08:58:09 IST
有可能吗?
答案 0 :(得分:1)
使用GNU date
:
$ TZ=GMT date -d '2017-01-29 08:58:09 IST' +'%F %T %Z'
2017-01-29 03:28:09 GMT
-d
选项指定要打印的时间(而不是“现在”),+'%F %T %Z'
输出格式字符串是%Y-%m-%d %H:%M:%S %Z
的缩写,TZ=GMT
设置{ {1}}命令的{1}}环境变量。