实际上我已经反序列化了这个json代码:
{
"id": "evt_17Uy2AJAW1ypyOFKd72w0Z6Q",
"object": "event",
"api_version": "2015-10-16",
"created": 1453204346,
"pending_webhooks": 1,
"request": "req_7kSy7UdDi03tB9",
"type": "invoice.payment_succeeded"
}
通过这个VB代码:
<Serializable>
Public Class StripeHookResponse
Public Property id As String
Public Property [Object] As String
Public Property api_version As String
Public Property created As Integer
Public Property pending_webhooks As Integer
Public Property request As String
Public Property type As String
End Class
Dim stripeResponse As StripeHookResponse =
Newtonsoft.Json.JsonConvert.DeserializeObject(Of StripeHookResponse)(str)
但stripeResponse.created
给出相同的值1453204346
。请使用VB.NET代码以dd-MM-yyyy
格式进行转换。
答案 0 :(得分:0)
希望此示例代码可以为您提供以下帮助
试试这个;请记住,JavaScript月份是0索引,而日期是1索引。
前端使用Javascript
<script>
var date = new Date('2010-10-11T00:00:00+05:30');
alert(date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
</script>
使用VB.NET后端
Dim thisDate1 As Date = #6/10/2011#
Console.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + ".")
Dim thisDate2 As New DateTimeOffset(2011, 6, 10, 15, 24, 16, TimeSpan.Zero)
Console.WriteLine("The current date and time: {0:MM/dd/yy H:mm:ss zzz}",
thisDate2)
' The example displays the following output:
' Today is June 10, 2011.
' The current date and time: 06/10/11 15:24:16 +00:00
按你想要的
Dim inp As String = "1204262016" Dim dt As DateTime =
DateTime.ParseExact(inp, "yyMMddHHmm", CultureInfo.InvariantCulture)
PS:你需要“Imports System.Globalization”
答案 1 :(得分:-2)
Public Shared Function UnixTimeStampToDateTime(ByVal unixTimeStamp As Double) As Date
' Unix timestamp is seconds past epoch
Dim dtDateTime As New Date(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime()
Return dtDateTime
End Function
dim req_date = UnixTimeStampToDateTime(stripeResponse.created)
它会给出答案
即19-01-2016 5:22:26 PM