Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:13:44+00:00 2026-06-02T02:13:44+00:00

Im having diffculty with datetime when its displayed client side from my rest web

  • 0

Im having diffculty with datetime when its displayed client side from my rest web service, my client side wpf app code looks like this:

    public MainWindow()
    {
        InitializeComponent();
        string uriGroups = "http://localhost:8000/Service/Student";
        XDocument xDoc = XDocument.Load(uriGroups);

        foreach(var node in xDoc.Descendants("Student"))
        {

            GroupBox groupbox = new GroupBox();
            groupbox.Header = String.Format(node.Element("StudentID").Value);
            groupbox.Width = 100;
            groupbox.Height = 100;
            groupbox.Margin = new Thickness(2);

            TextBlock textBlock = new TextBlock();
            textBlock.Text = String.Format(node.Element("FirstName").Value + " " + (node.Element("LastName").Value));
            textBlock.TextAlignment = TextAlignment.Center;

            TextBlock textBlock1 = new TextBlock();
            textBlock1.Text = String.Format(node.Element("TimeAdded").Value);
            textBlock1.TextAlignment = TextAlignment.Center;
            textBlock1.VerticalAlignment = VerticalAlignment.Bottom;

            StackPanel stackPanel = new StackPanel();
            stackPanel.Children.Add(groupbox);

            stackPanel.Children.Add(textBlock);
            stackPanel.Children.Add(textBlock1);
            stackPanel.Margin = new Thickness(10);

            MainArea.Children.Add(stackPanel);
        }

    }

And my service looks like this:

public class Student
{
    ....
            public DateTime TimeAdded;
        public string TimeAddedString
        {
            get
            {
                return this.TimeAdded.ToString("dd/MM/yyyy hh:mm:ss");
            }
        }

But the output looks like this:

enter image description here

Is there a way on my client side app code to truncate this or reformat it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:13:46+00:00Added an answer on June 2, 2026 at 2:13 am

    You can cast it to a DateTime and then use String.Format

    Here is an example with one format you could use:

    String.Format("{0:M/d/yyyy}", ((DateTime)node.Element("TimeAdded").Value))
    

    You can also use DateTime.ToString(FORMAT)

    ((DateTime)node.Element("TimeAdded").Value).ToString("d");
    

    I have made an assumption that .Value returns an object, but if it returns a DateTime then you can drop the casts.

    If you are getting a string into your client, then you will need to use DateTime.Parse

    (DateTime.Parse(node.Element("TimeAdded").Value)).ToString("d");
    String.Format("{0:M/d/yyyy}", DateTime.Parse(node.Element("TimeAdded").Value))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having difficulty scraping dates from a specific web page because the date is
I am having difficulty connecting my java code to sql server database. I can
I'm having difficulty figuring out how to clone my Mercurial repository from my local
I am having difficulty with the following code which is inside a static method
I'm having difficulty converting some NSOperation code to ARC. My operation object uses a
IE is having diffculty with dynamic urls in the jQuery load function. Here's my
I'm having a difficult time trying to load System.Data.SQLite.dll from PowerShell in Windows 7
I'm having trouble formatting a datetime.timedelta object. Here's what I'm trying to do: I
I am trying to fill a list with random numbers and am having diffculty
I am having difficulty executing a MS SQL Server stored procedure from Java/jsp. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.