如何将“字符串”转换为“没有时区的时间戳”

我是Postgresql的新手,我正在使用WCF服务。
这是我的代码片段:

$.ajax({ url: '../Services/AuctionEntryServices.svc/InsertAuctionDetails', data: JSON.stringify({ "objAuctionEntryEntity": { "AuctionNO": '', "AuctionDate": $('[Id$="lblAuctionDateVal"]').text(), "TraderID": $('[Id$="ddlTraderName"] option:selected').val(), "Grade": $('[Id$="ddlGrade"] option:selected').val(), "Varity": $('[Id$="ddlVarity"] option:selected').val(), "QuntityInAuction": $('#txtQuantityForAuction').val(), "AuctionRate": $('#txtAuctionRate').val(), "BrokerID": a[0], "IsSold": $('#chlIsSold').is(':checked'), "CreatedBy": $.parseJSON(GetCookie('Admin_User_In_Mandi')).UserID, "UpdatedBy": $.parseJSON(GetCookie('Admin_User_In_Mandi')).UserID, "CreationDate": GetCurrentDate().toMSJSON(), "IsActive": true, "AuctionTransaction": arrAuctionTransaction, "MandiID": $.parseJSON(GetCookie('Admin_User_In_Mandi')).MandiID, "FarmerID": _ownerid, "AuctionNO": _auctionno, "AmmanatPattiID": _ammantpattiid, "ToTraderID": b[0], "ToTraderName": $('#txtOtherBuyerNameEN').val(), "ToTraderName_HI": $('#txtOtherBuyerNameHI').val() } }), type: 'POST', contentType: 'application/json', dataType: 'json' }); 

这里:

 $('[Id$="lblAuctionDateVal"]').text() = "20/8/2013 14:52:49" 

此字段的数据类型是timestamp without time zone
如何将此字符串转换为timestamp without time zone数据类型的timestamp without time zone

timestamp字符串表示forms(= timestamp without time zone )取决于您的区域设置。 因此,为避免导致数据错误或Postgres咳嗽exception的歧义,您有两种选择:

1.)使用ISO 8601格式 ,它与任何语言环境或DateStyle设置相同:

 '2013-08-20 14:52:49' 

您可能仍然需要显式地转换字符串,其中数据类型不是先验已知的,具体取决于用例:

 '2013-08-20 14:52:49'::timestamp 

2.)使用带有匹配模板模式的to_timestamp() 将字符串转换为timestamp

 to_timestamp('20/8/2013 14:52:49', 'DD/MM/YYYY hh24:mi:ss') 

要将字符串转换为不带时区的时间戳,对于Postgresql,我使用上面的内容

 SELECT to_timestamp('23-11-1986 09:30:00', 'DD-MM-YYYY hh24:mi:ss')::timestamp without time zone;