Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting the value like this from Json "2018-02-13T00:16:26+08:00".
I want to display same thing at UI but that formate is modifying and displaying some format.
Could you please suggest that how to display same value in UI.

What I have tried:

I have tried like objMonitoringSearch.LogTime = item.logTime.ToString("yyyy-MM-ddTHH:mm:ss z")
Getting different value at UI like this "2018-02-13T00:16:26+08".
Could you please help me.
Posted
Updated 18-Feb-18 23:55pm

1 solution

Hi,

First you need to convert your date string into date-time format,than convert it into desire format.
Regards,
Sarita Singh
 
Share this answer
 
Comments
DGKumar 19-Feb-18 8:16am    
I want to display same value in UI with out convertion is is possible?
"2018-02-13T00:16:26+08:00"
DGKumar 20-Feb-18 0:11am    
I am getting json data like below
"logTime": "2017-10-19T15:36:22+08:00"
i am converting the json data like below
dynamic stuff = JsonConvert.DeserializeObject(strFinalJson);
foreach (var item in stuff)
{

objMonitoringSearch.LogTime = item.logTime;

}

Here the loTime is converted but i want to display same value without convert .
Could you please help onthat.
Sarita Mall 21-Feb-18 0:35am    
Hi DG,

Take a lable on .aspx and on code behind use below code. Same result shown like you want. Please let me know for any confusion further.

using System;
using Newtonsoft.Json;

namespace yournamespace
{
public partial class testpage1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strFinalJson = "{'logTime': '2017-10-19T15:36:22+08:00'}"; //jsonsting Sample
dynamic stuff = JsonConvert.DeserializeObject<objmonitoringsearch>(strFinalJson.ToString());
Label1.Text = stuff.logTime;
}

public class objMonitoringSearch
{
public string logTime { get; set; }
}
}
}

Regards,
Sarita

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900