PDA

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



RCN
Nov 06, 2012, 8: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

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

RCN
Nov 07, 2012, 2: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

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

RCN
Nov 07, 2012, 10:51 AM
Thannk you Geoffrey

RCM
Dec 03, 2012, 6:13 PM
Hi ,

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

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

RCN
Dec 03, 2012, 6:26 PM
It has two overloads:



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

RCM
Dec 03, 2012, 7:01 PM
hi,

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

The list can be found here:
http://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.71).aspx

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

geoffrey.mcgill
Dec 04, 2012, 3:29 AM
A Format Specifier is a string.

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

Example


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

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


Hope this helps.

RCN
Dec 04, 2012, 12:22 PM
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.

johnsonjeven
Dec 14, 2016, 6: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)

Johnson