I have my database server located in U.S. The user makes entry from INDIA the date must be stored of client and not the server. but, unfortunately the server date is stored in database. I am showing the entries to user only of the current date that are made on the day only. Problem is when user enters record till 12:30 PM(Client Machine) are being displayed to user but after 12:30PM (Client Machine), the entries are not being displayed only the entries made after 12:30 PM(Client Machine) are displayed.Any Idea?
Eg: Entry done at 06/05/2013(DD/MM/YYYY) till 12:30 PM are shown when client machine date is 06/05/2013 11:57 AM but when client machine date is 06/05/2013 12:57 PM the entries enterd are not displayed but entries made after 12:30 PM are displayed. In DB for above eg. created date is stored as 05/05/2013 don't know why? In .cs file:
public static DateTime GetIndianDate(DateTime dateTime)
{
return TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dateTime, TimeZoneInfo.Local.Id,"India Standard Time").Date;
}
To show todays entries only:
shipments = BLL.GetShipmentsByUserIdNDate(userId, Classes.Common.GetIndianDate(DateTime.Now.Date));
public static List<Shipment> GetShipmentsByUserIdNDate(Guid userId, DateTime dateTime)
{
Entities db = new Entities();
List<Shipment> shipments = (from s in db.Shipments
where s.UserId == userId && s.CreatedDate == dateTime
select s).ToList();
return shipments;
}
While Inserting:
shipment.CreatedDate = Classes.Common.GetIndianDate(DateTime.Now.Date);
public static DateTime GetIndianDate(DateTime dateTime)
{
return TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dateTime, TimeZoneInfo.Local.Id,"India Standard Time").Date;
}
So, How will i store the date of client machine? now it still stores servers date only.
Help Appreciated!