View Full Version : Converting date format from C# to Ext

Nov 06, 2012, 7:27 PM
For information purposes only: in case of someone need to convert date format from C# to Ext, please use Ext.Net.Utilities.DateTimeUtils.ConvertNetToPHP method, as shown bellow:

string formatConverted = Ext.Net.Utilities.DateTimeUtils.ConvertNetToPHP("dd/MM/yyyy HH:mm:ss", null);
//formatConverted = d/m/Y H:i:s

Nov 06, 2012, 8:17 PM
Thanks for passing along this DateTime format tip. I'm sure it will help others in the future.

Nov 07, 2012, 1:41 AM
I hope so. Geoffrey, what about we open a Tips area in the forum? i say it because for me it's strange to post a tip in this area. it would be nice to see other users just reading the tips and discovering new approaches to solve common problems

Nov 07, 2012, 3:15 AM
I have moved this thread to the "Examples and Extras" forum. Maybe I'll change the forum name to "Examples and Tips".

Nov 07, 2012, 9:51 AM
Thannk you Geoffrey

Dec 03, 2012, 5:13 PM
Hi ,

Does ConvertNetToPHP accepts format specifiers as well or it only accepts format strings.

Dec 03, 2012, 5:25 PM
What do you mean with "format specifiers"?

Dec 03, 2012, 5:26 PM
It has two overloads:

public static string ConvertNetToPHP(string format);
public static string ConvertNetToPHP(string format, CultureInfo culture);

Dec 03, 2012, 6:01 PM

Examples of Format specifiers are :
d - Short date pattern
D - long date pattern

The list can be found here:

Dec 03, 2012, 6:19 PM
I tested and unfortunately it does not support format specifiers

Dec 04, 2012, 2:29 AM
A Format Specifier is a string.

The ConvertNetToPHP Method will convert "d" and "D" to their PHP equivalents.


var format = Ext.Net.Utilities.DateTimeUtils.ConvertNetToPHP("d");

X.Msg.Notify("Format", format).Show();

Hope this helps.

Dec 04, 2012, 11:22 AM
I'd like to apologize for stating that it was not possible when it is.

I got an NullReferenceException when i ran the the following code:

Ext.Net.Utilities.DateTimeUtils.ConvertNetToPHP("d", null);

so i thought that it was not possible.

Dec 14, 2016, 5:40 AM
try use c# TryParse method...

public static bool TryParse(
string s,
out DateTime result

This method is similar to the DateTime.Parse(String) method, except that the TryParse(String, DateTime) method does not throw an exception if the conversion fails. More about...date conversion (http://net-informations.com/q/faq/stringdate.html)