我想将带时区的日期时间对象存储为字符串。为了确保它们的格式正确,我想使用一个正则表达式作为验证器。日期时间对象在PostgreSQL中的存储方式如下:
protected void Button3_Click(object sender, EventArgs e)
{
viewrecord s = new viewrecord();
s.std_id = Convert.ToInt32(TextBox2.Text);
SqlConnection conn2 = new SqlConnection(connstring);
try
{
SqlDataAdapter da = new SqlDataAdapter("viewrecord", conn2);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@std_id", s.std_id);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataSourceID = "";
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Redirect("ErrorMsgBoxBack.aspx");
}
finally
{
conn2.Close();
}
不言自明。当然,时区部分是可选的,因此正则表达式模式也需要考虑这一点。现在,我正在这样做:
'2004-10-19 10:23:54+02'
我不能完全确定这是正确的,尤其是时区部分。这会匹配可以存储在PostgreSQL数据库中的所有可能的时区吗?感谢您的帮助。
编辑:我没有将其直接存储在PostgreSQL数据库中,因此我仍然需要正确使用正则表达式。
答案 0 :(得分:1)
如果您拥有字符串类型的值,则可以尝试使用$(document).ready(function() {
var index = 0;
var id = [];
$('#button1').on('click', function() {
$('body').append($("<div id='chart-" + index + "'></div>"));
Highcharts.chart('chart-' + index, {
series: [{
data: [1, 2, 3]
}]
});
var temp="$('#chart-"+index+"')";
id.push(temp);
console.log('chart' + index);
index++;
});
$('#download').on('click', function() {
var string = JSON.stringify(id);
var strreplace = string.replace (/"/g,'');
console.log(strreplace);
var elements = [$('#chart-0'),$('#chart-1')];
console.log(elements);
});
});
函数作为选项:
/Library/Caches