วันที่ JavaScript
var now = new Date(); //วันที่ปัจจุุบัน
var dateTime = new Date("2019-06-01 14:24:36");
dateTime1 = moment(dateTime).format("YYYY-MM-DD HH:mm:ss");
dateTime1 = moment(now).format("YYYY-MM-DDTHH:mm:ssZ");
...
...
...
Date :
2019-06-10 20:17:40
By :
หน้าฮี
No. 4
Guest
ลองดูของจริงนะ
Code (VB.NET)
Imports System.Globalization
'ชั่วโมงที่ผ่านมา ทำทำอะไรไปบ้าง ยิกยิกยิก
Dim StringDate = DateTime.Now.AddHours(-1).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US"))
Code (VB.NET)
''' <summary>
''' Usage: https://localhost:6969/api/Sura/GetGoogleMapLocations
''' </summary>
''' <returns>List of (Id, Text, Remark[warehouseCN/provinceN]) From id_wherehouse/id_province (ตาราง โรงกลั่นน้ำมัน+จังหวัด)</returns>
<Route("GetGoogleMapLocations")>
<HttpGet>
Public Async Function GetGoogleMapLocations() As Task(Of IActionResult)
Dim lstLocation As New List(Of GoogleMapLocations)
Dim sb As New System.Text.StringBuilder()
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddMinutes(-5).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddMinutes(-15).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddMinutes(-30).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddMinutes(-45).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddHours(-1).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddHours(-3).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddHours(-6).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddHours(-12).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddHours(-18).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "';")
sb.Append("select sum(rain_mm) as rain_mm from tran_node_data where time >= '" & DateTime.Now.AddHours(-24).ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "' and time <= '" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.CreateSpecificCulture("en-US")) & "'")
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC10", .PKName = "บ้านท่าตะคร้อ", .Lat = 13.116442, .Lng = 99.73253, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC11", .PKName = "บ้านห้วยกวางจริง", .Lat = 13.005129, .Lng = 99.74265, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC12", .PKName = "เขื่อนเพชร (เหนือน้ำ)", .Lat = 12.91296, .Lng = 99.85525, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC13", .PKName = "เขื่อนเพชร (ท้ายน้ำ)", .Lat = 12.914403, .Lng = 99.85451, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC14", .PKName = "ท่ายาง", .Lat = 12.973196, .Lng = 99.88275, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC15", .PKName = "บ้านลาด", .Lat = 13.048535, .Lng = 99.91988, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC16", .PKName = "เมืองเพชร", .Lat = 13.121885, .Lng = 99.95282, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC17", .PKName = "บ้านแหลม", .Lat = 13.2124, .Lng = 99.98281, .Title = "", .Description = "", .MarkerColor = "red"})
lstLocation.Add(New GoogleMapLocations() With {.PK = "TTC17", .PKName = "บ้านชอบเลียหอย", .Lat = 69.2124, .Lng = 96.98281, .Title = "", .Description = "", .MarkerColor = "red"})
Await Task.Delay(0)
Return Ok(lstLocation.ToList())
End Function