Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

User Image
Leon André Bergman
60 discussion posts
Hi.
I'm using a macro to output a date and the current time +1 second, but the place that I send it to needs the format to be in english, and not Norwegian.

I'm using the following code:

Code

int secondsToAdd = 1;
                DateTime currentDateTime = DateTime.Now;

                DateTime newDate = currentDateTime.AddSeconds(secondsToAdd);
                 text = newDate.ToString("HH:mm:ss dd MMMM yyyy");
        BFS.Clipboard.SetText(text);


When I paste it it outputs Desember, instead of December.
I just noticed the issue as I started using this in November, which is spelled the same way in both languages.
Is there a way I can make it use english form of the word?

My googling found some info about CultureInfo but it didn't accept it.
Dec 2, 2019  • #1
PabloMartinez's profile on WallpaperFusion.com
First of all, you need to add System.Globalization namespace to define CultureInfo. Then into the formatted string you specify CultureInfo.InvariantCulture

Code

using System;
using System.Collections.Generic;
using System.Globalization;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        var secondsToAdd = 1;
        var currentDateTime = DateTime.Now;
        var newDate = currentDateTime.AddSeconds(secondsToAdd);
        var time = newDate.ToString("HH:mm:ss dd MMMM yyyy", CultureInfo.InvariantCulture);
        BFS.Clipboard.SetText(time);
        return null;
    }
}
Dec 3, 2019  • #2
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)