|
thanks for reply.
1) would you post some code to grab the offset between local date and time and UTC date and time.
2) would show how to convert utc date and time to local one if we know the offset ?
please share the knowledge if possible. thanks
tbhattacharjee
|
|
|
|
|
It depends on the used language and the used DateTime format.
If you have a format that uses the elapsed seconds or milliseconds since some epoch, just do addition / subtraction.
If you have a DateTime class, use the provided class functions to add/subtract time spans and get the difference between two objects. These classes have usually also functions to convert between UTC and local time using the user or system settings for the local time zone.
For JavaScript see for example Date - JavaScript | MDN[^].
For .NET see DateTime Structure (System)[^].
There is usually no need to get the offset. Use conversion functions instead.
The only situation to use an offset might be when it is configured by a user setting on the server (e.g. the user has specified his time zone). Then use the language dependant addition method with a time span set to the offset.
With .NET DateTime , use for example DateTime.ToUniversalTime Method (System)[^] and DateTime.ToLocalTime Method (System)[^]. But note that the object must be in the source format (when using ToLocalTime for example, the object must contain a UTC time).
|
|
|
|
|
i guess if i store date time in utc format and if i store also offset then i can convert utc date time to local one just adding or subtract offset hours from UTC date and time. am i right ?
tbhattacharjee
|
|
|
|
|
Yes, you are right.
But storing is only necessary if you want to track this kind of information (the local time of the system that has created the time stamp). This is often not necessary because you usually show local times using the time zone of the system displaying the time.
If for example a time stamp is created by a user in India and another user somwhere in the U.S. is viewing the related data, it makes more sense to show it in the local time of the viewer or even UTC rather than using the Indian time.
|
|
|
|
|
suppose i have web UI from where user post issue. our web UI and db hosted in USA pc. now user can appear from any country and post issue.
from my web UI i am sending user issue details and user pc date and time to server side function.
now my question is how could i convert client pc date and time to utc date and time at server side before storing in db ?
again how could i show client date and time in his local date and time if i know client time zone.
so here i have two question how to convert client date and time. for example say i capture client date and time by javascript 25/01/2017 03:08:01 and send it to server side function. now how could i convert client date and time 25/01/2017 03:08:01 to UTC date and time ?
again how could i later convert utc date and time to client local time if i know client timezone.
please help with sample code if possible.
thanks
tbhattacharjee
|
|
|
|
|
Important: Always use UTC and binary types (no local time and no strings)!
When data must be send as strings use a universal format like ISO 8601 - Wikipedia[^].
On the client side get the time as UTC (e.g. using JavaScript Date().getTime() ) and send that to the server.
Handle and store them on the server side as UTC.
To display them they may be optionally converted to the client's local time.
When this is done on the client side, use appropriate functions (just search for "<language> utc to local").
When this is done on the server side the time zone used by the client must known. This can be for example stored in the user record of the login database like here at CodeProject (see your profile settings).
To convert times when having an offset (timezone offsets are usually defined in minutes) just use the Add method of the DateTime class of the used language.
|
|
|
|
|
i guess this code Date().getTime() will show me time only but i need client local date and time. so tell me which one i should use ?
1) if possible show me what JavaScript code i need to use to grab the client local date and time.
2) how to convert that client local date and time to UTC at server side by c# code ?
please share code example for my question if possible. thanks
tbhattacharjee
|
|
|
|
|
Again:
Don't get the local time on the client. Get the UTC time. Do all operations with UTC. Only when displaying local time is required convert to local time for displaying.
When the time stamp is going to be stored in a database on the server there is even no need to get it on the client. Get it on the server instead. This will also avoid wrong times (the clients clock may be wrong) and time deviations between clients (clocks of clients may be not exact).
See my answer to the above thread for references.
|
|
|
|
|
are you trying to say grab client utc date time instead of local date time ?
how to grab client utc date time by javascript ?
for my second question please include a small js code. thanks
tbhattacharjee
|
|
|
|
|
It depends on what you want to do with the time stamp.
If you want to send it to server:
That is not necessary as already explained. Let the server get the time of receiving the client's request.
If you want to process it on the client use the format (UTC or local) according to your requirements.
To get the current time just use Date.now() - JavaScript | MDN[^].
|
|
|
|
|
i know unit testing but not familiar with integration testing and regression testing.
it will be really helpful if some one explain what is integration testing and regression testing with sample example. thanks
tbhattacharjee
|
|
|
|
|
|
thanks for answer.integration testing & regression testing can be automated instead of manual testing?
VS2013 has any extension which we can use to automate integration testing & regression testing.
please guide me. thanks
tbhattacharjee
|
|
|
|
|
Not sure about the tools, I'm not a tester, but most test teams use tools like Selenium to automate integration and regression testing. Visual Studio comes with a test runner that lets devs do unit tests etc and lets build servers run the tests also.
|
|
|
|
|
Regression testing really can't be automated, as it's based on the functionality from a use case standpoint.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Nathan Minier wrote: Regression testing really can't be automated,
ORLY? So if you had a login\registration\etc process on a site and you want to check some bug fixes to email address validation haven't broken anything are you saying you can't automate the basic functions of the site to ensure they still work?
|
|
|
|
|
I would call that integration testing rather than regression testing. To my view, a user (with their fun foibles) is an essential system component in a regression test.
Opinions may vary
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Integration testing is focused more on recent developments etc, whereas regression is a sweep of the entire solution to ensure everything is still working as it should as updates in one part often have a tendency to break code elsewhere that the developer isn't looking at. The difference is mainly ideological and also with scope, the tools you use will be (or can be) the same, however the regression tests will have a larger scope and will be triggered at different times or under different circumstances.
|
|
|
|
|
Hi,
Hopefully correct forum.
I have been using Discount ASP to host my site for the last 6 years+.
Really pleased with them, great support and works well and they have a UK data centre option.
I was looking at their Everleap service (built on MS Azure), which looks great as it isolates you from most of the brain ache of having a VPS or MS Azure.
But they don't have a UK data centre option for this service, big disappointment!
I am worried that if I use the west coast (I think) US based Everleap service my websites page load times will increase significantly.
So I have two questions....
1 Does anyone know of a similar service to Everleap that has a UK data centre option?
2 Are my concerns regarding increased page load times of a west coast US hosted site overblown?
I already use a CDN for all my static content.
Many thanks to everyone in advance,
Will
|
|
|
|
|
|
|
Do not repost on the forums, that is not allowed.
The only difference is the hyperlink, if you needed to just change from clear text to hyperlink, you can always click on "Edit" under the message and update what you want to. Reposting doesn't help at all — also previous post remains similar and ambiguity remains intact.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Please remove hyperlinks from your questions. You are in danger of being mistaken for a spammer and getting kicked off the site.
|
|
|
|
|
Hello,
Total stranger to ASP.Net here.
We have been advised by our server hosts that the code attached which is used to send a form to an email recipient should have a single constant "From" email address specified to avoid SPF related issues. At the moment the "From" is retrieved from the email form field.
thanks,
Richard
About Me:
I'm new in this forum, I am a consultant and have worked with multiple firms
You can check Accounting software videos one of my work.
|
|
|
|