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 7499613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:53:10+00:00 2026-05-29T19:53:10+00:00

I feel like this is something I’ve done a thousand times so not sure

  • 0

I feel like this is something I’ve done a thousand times so not sure why it is being so difficult now. I’ve created a method that simply returns Today’s date for the user based on their UTC offset. But instead of returning a string resembling a date, it is returning this garbage

"䙭/䙭/Ἰ뻱䙭"

Here is the code.

public string getToday(Context context)
{
    var settings = PreferenceManager.GetDefaultSharedPreferences(context);
    var offset = settings.GetInt("offset", -5);
    var now = DateTime.UtcNow.AddHours(offset);

    return now.ToShortDateString();
}

When I step into the code using a breakpoint, offset and now both seem correct. now contains valid date parts all appearing to be accurate. Something about converting now to a string seems to go horribly wrong. Also tried:

return now.ToString("MM/dd/yyyy");

Same result. Weird part is the below code in another activity works without issue

var offset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours;
var now = DateTime.UtcNow.AddHours(offset);
now.ToString("MM-dd-yyyy")
  • 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-05-29T19:53:11+00:00Added an answer on May 29, 2026 at 7:53 pm

    I assume that your device is set to a Chinese/Japanese/Korean culture. If you always want to return US dates, use:

    return now.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
    

    Edit: Given the rest of your comments, I’m starting to suspect that this might be caused by corruption, or by a bug in the MonoDroid implementation. You could try working around it by constructing the date manually (although this admittedly doesn’t address the cause of your issue):

    return string.Format("{0:00}/{1:00}/{2:0000}", now.Month, now.Day, now.Year);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this is something I should already know, but I'm just not
I feel like this is something that I should have learned by now, and
I feel like this is easy but I am missing something... Using jQuery, I
I feel like this should be a no brainer, but clearly I'm missing something...
I feel like this might be really simple but I'm just not getting it
I feel like this is not a very efficient way of using linq. I
Something like this (yes, this doesn't deal with some edge cases - that's not
I'm trying to accomplish something like this. I feel like it's possible, and if
Feel like this should be something easy that I'm missing. I have a table
I feel like this is something that Google should be able to solve for

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.