in my client side i get an object with a datetime property so when i send the object to the server side i send it in json format so when i try to use that property appears in a different format.
the original datetime property is "2016-03-09T17:16:33" and when i try to use that property appears like this: "09/03/2016 05:16:33 p. m."
what i want is to avoid that cast, or reformat the property to the original format.
im using Newtonsoft.Json to handle the json in the server side.
this is the client side´s object (angularjs)
var factura = {
comprobante:{
fecha:"2016-03-09T17:16:33",
version:"3.2",
tipoDeComprobante:"comprobante",
formaDePago:"Efectivo",
subTotal:"123123.123",
total:"4234234",
metodoDePago:"deposito",
LugarExpedicion:"guadalajara"
},
cliente:{
token:"69113116100"
},
receptor:{
rfc:"234dfdg3gfdgsg42",
domicilio:{
pais:"Mexico"
}
},
emisor:{
rfc:"234dfdg3gfdgsg42",
domicilioFiscal:{
calle:"san cristobalito",
municipio:"zapopan",
estado:"jalisco",
codigoPostal:"3434",
pais:"mexico"
},
regimenFiscal:{
Regimen:"regimen"
}
},
conceptos:
[
{
cantidad:"234",
unidad:"1.0",
descripcion:"descripcion",
valorUnitario:"decimal",
importe:"importe"
},
{
cantidad:"234",
unidad:"1.0",
descripcion:"descripcion",
valorUnitario:"decimal",
importe:"importe"
}
],
impuestos:{
traslado:[
{
impuesto:"1.3",
tasa:"2.5",
importe:"importe"
},
{
impuesto:"1.3",
tasa:"2.5",
importe:"importe"
}
],
retencion:[
{
impuesto:"1.3",
tasa:"2.5",
importe:"importe"
},
{
impuesto:"1.3",
tasa:"2.5",
importe:"importe"
}
]
},
tieneComplementoDonat:"0"
};
and this is my server side´s code as you can see in the comprobante.SetAttributeValue(DatosComprobante[y].NombreDato, objeto["factura"]["comprobante"][DatosComprobante[y].NombreDato]);
method i insert the properties in a XElement node so when the property "fecha" comes in the for loop, it appears different as i sent it from client's side.
i think is something about to disable the deserialization to get only the raw string because when i see the "objeto" variable in the debugger the date appears correctly.
public XElement retornaNodoXml(JObject objeto)
{
Domicilio domicilio = new Domicilio();
Dato dato = new Dato();
XElement comprobante = new XElement("cfdi" + dato.ComodinCfdi + "Comprobante");
for (int y = 0; y < DatosComprobante.Count; y++)
{
if (objeto["factura"]["comprobante"][DatosComprobante[y].NombreDato] != null)
{
comprobante.SetAttributeValue(DatosComprobante[y].NombreDato, objeto["factura"]["comprobante"][DatosComprobante[y].NombreDato]);
}
}
return comprobante;
}