i have my Angular code like so:
export interface angularModel {
name: string;
createdOnDate: Date;
decision: {
id: number;
createdOnDate: Date;
}
}
const now = new Date();//outputs Thu Sep 15 2022 09:19:05 GMT-0700 (Mountain Standard Time)
const document = new angularModel();
document = {
name: 'Bob',
createdOnDate: now
decision: {
id: 1,
createdOnDate: now
}
}
but on the API side, this is received as:
CustomModel document = {
Name: "Bob",
CreatedOnDate: {9/15/2022 9:19:05 AM},//which is correct
AutoGeneratedModel Decision: {
Id: 1,
CreatedOnDate: {9/15/2022 4:19:05 PM}//which is wrong
}
}
the CustomModel is setup like this:
using System;
using System.Collections.Generic;
namespace Project.Models
{
public class CustomModel
{
public string Name { get; set; }
public DateTime CreatedOnDate { get; set; }
public AutoGeneratedModel Decision { get; set; }
}
}
and the AutoGeneratedModel is setup like this:
namespace Project.Contexts
{
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
[DataContract(IsReference=true)]
public partial class AutoGeneratedModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
public System.DateTime CreatedOnDate { get; set; }
}
}
and i have no idea why the time zone changes in the one instance.