How to get DateTime object in french culture - c#-4.0

I am working on an application which have 2 language versions. In this app I am creating a DateTime object for 1st day of the month.
e.g.
DateTime startOfMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
The output comes out as;
11/1/2013 12:00:00 AM
in english version
However in french version it comes out as
The culture becomes 'fr-CA' in this case
11/1/2013 00:00:00
Can anyone help me in getting value similar to english version ?
With string.Format this can be achieved but I need DateTime object not string.
Thanks in advance.

Take a look here
http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx
Something like this should work
date1.ToString("MM/dd/yy H:mm:ss zzz")

To custom format your date object, format it with 12 hour time. As you can see in english version it is showing date in 12 hour format and in french version it is showing date in 24 hour format. So format it like:
date.ToString("MM/dd/yyyy hh:mm:ss tt");
or
date.ToString("M/d/yyyy h:m:s tt");

Related

Sql developer importing excel date in 12 hour formay

I'm trying to import date column using SQL developer but it's always changing to 12 hour format on import i.e if time is 18:00 it's importing as 6.
Could you please help with this ? I tried changing the nls in preferences and also tried changing system data format but it isn't working.
Sure, you want to be sure to make use of the Date Format entry on the wizard for the column you're reading from Excel during the Import wizard.
For your date, make sure you are using HH24 and not HH to represent the time.
A date in the Excel file:
Then as it's imported using a format date of 'MM/DD/RR HH24:MI'
18-06-1987 14:00:00

How can I split" Feb 9 2022, 9:55 PM" in excel by a formula?

The Format is Date
=INT() didn't work
Just because you format it as a date does not make it so. This is probably a date stored as text not a true date which if you changed to general format would change to a number. You will need to parse the string and put the "date" in a format that excel can understand then take the INT to get just the date:
=INT(--REPLACE(SUBSTITUTE(A1,",",""),FIND("{{{",SUBSTITUTE(A1," ","{{{",2)),0,","))
One note, this method only works if the month value like Feb is in the local language. If one has a local language of Portuguese Feb is not the correct abbreviation, and as such will fail.
Use the builtin date functions Day() Month() Year() Hour() Minute().

How to change the date format that primefaces give with this calendar? [duplicate]

I've been searching all over and just can't find a explanation or reason why this is happening but the parse(String) method of DateFormat just isn't parsing my String correctly.
I'm trying to parse a String into the date format that is used for HTTP headers and got as far as getting the String on its own such as:
Thu, 11 Nov 2010 18:34:22 GMT
Which is in the format:
E, d MMM yyyy HH:mm:ss z
But when I use df.parse(dateStr); this is what I get out of it:
Thu Nov 11 18:34:22 GMT 2010
Which is nothing like what I wanted, why is the year now after the GMT? Why is there no comma anymore? And why is the date after the month?
I'm completely confused about this now and can't find a solution but I really need the date to be in that format. Is the comma messing things up? or the colons?
Thanks for your time,
Infinitifizz
P.S.
Forgot to mention this but I've tried dateformat.setLenient(false) and it makes no difference.
P.P.S
I'm trying to do this to compare the dates with date1.before(date2) and after() etc to see if one is newer than the other but I can't do this because the parsing isn't working.
Even though they look the same but just the format is different, they are not the same because after calling getTime() on both of them (When I have provided 2 identical dates) the longs are not the same. As in the date is:
Thu, 11 Nov 2010 19:38:52 GMT for a lastModified() on a File
If I input the String "Thu, 11 Nov 2010 19:38:52 GMT" and then compare their longs once converting the string to a date using parse() and then calling getTime() on that date I get:
lastModified = 1289504332671
fromString = 1289504332000
It is only the last 3 digits that are different, does this have any significance?
Thanks again for your time and sorry I didn't put this bit in first,
Infinitifizz
The result format is the default format of Date#toString() (click link to see the javadoc). You're apparently doing a System.out.println(date). You would like to use SimpleDateFormat#format() instead with another pattern to format it in the desired format. E.g.
String newDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
Update: You shouldn't care about the format when using Date. You should only care about the format at that point when Date is to be converted (displayed) as String. As to the difference in timestamps, the Date uses millisecond precision for the timestamp while HTTP header uses second precision. You'd like to divide the timestamps by 1000 before comparing.

Time changes when converting date into ISOString in nodejs

I've got a date string from my database which has this format:
Tue Nov 12 2013 18:14:46 GMT+0100 (CET)
I want to convert it into a ISOString and im currently doing that with:
var iso = new Date(val.text_date).toISOString();
However for some reason the output time is moved 1 hour backwards?
This is the output im getting:
2013-11-12T17:14:46.000Z
How can i avoid this?
Short answer: the time is converted into UTC, and your original time was displayed in UTC+1, hence the one hour difference.
The Date.toISOString() method converts the date into a string in the ISO 8601 format. Note that the returned date in your example ends by a Z: 2013-11-12T17:14:46.000Z. As per the Mozilla documentation and Wikipedia:
If the time is in UTC, add a Z directly after the time without a
space. Z is the zone designator for the zero UTC offset

How to get AM/PM in System Date and Time in MFC(VC++ )?

How to get AM/PM in System date and time in this format (15-Nov-2010 16:24 PM) in MFC ?
Any help is appreciated.
Use COleDateTime::Format with the correct format string.

Resources