Change timezone of openshift DIY application - timezone

I have created the DIY application in the openshift. Now I want to change the default timezone of my application server.I tried some normal linux methods to do so but could not able to do so, due to root permission problem.Please tell me how can I do this.
Thanks,
Vinay

I had same problem with timezone in my diy app (clojure), as i use jvm these worked for me
export JAVA_OPTS="-Duser.timezone=Europe/Moscow"
in .openshift/action_hooks/start

You will not be able to change the timezone on the server as that would require administrative priviledges. If you would like a specific timezone to be used in your code then you would need to account for that using whatever programming language you are using for your application. You should be able to easily use UTC or whatever you would like.

Related

Change browser timezone in cypress.io (Windows) [duplicate]

I just wrote a little piece of code to show the server time in a webpage. At the moment I just have one machine so I cannot test if the code is working.
Is there a way to tell the browser to use a time configuration different from the one configured in the OS? I have used plugins for Firefox to test different locales, I wonder if there are similar options for time tests.
Thanks.
Create a new empty directory for a separate Chrome user profile. E.g. with
mkdir ~/chrome-profile
You specify the TZ environment variable. You can see the valid timezones for example here, in column TZ.
To start Chrome, use these commands:
for Mac OS X: TZ='US/Pacific' open -na "Google Chrome" --args "--user-data-dir=$HOME/chrome-profile"
for Linux: TZ='US/Pacific' google-chrome "--user-data-dir=$HOME/chrome-profile"
Unfortunately, JavaScript is only aware of the current time zone, as it is set by the operating system. There are no facilities to let the Date object use a different time zone in a particular context. There are some libraries to do time zone conversions, but that won't help for what you are asking.
On Linux, Mac OSX, and other *NIX systems, you can set the TZ environment variable. See Benedikt Köppel's answer for details.
However, there is no facility for this on Windows. Some Windows programs may pick up on the TZ environment variable, but those that do will not necessarily interpret it correctly, as they aren't wired up to support IANA time zone names. More on this here and here.
You don't need to change OS variables or extensions to do this in 2021.
Chrome Dev Tools > Hamburger Menu > More Tools > Sensors
On the Location section select your location or give it a timezone id (e.g. America/Chicago, America/New_York)
On popular demand (kidding!), the explanation.
Google Chrome reads the environment variables to get the timezone its running in. Apparently all instances of Chrome share the value (not tested). In order to force a timezone, we need to a) set the environment variable to the timezone we want, b) kill all existing instances of Chrome, c) Print the current timezone to confirm, and d) Start Chrome with the intended timezone.
The below shell script is tested with OS X but should work for others too.
export TZ='US/Pacific'
killall Chrome
date
open /Applications/Google\ Chrome.app
Chrome seems to update its TimeZone as soon as you change it in Windows. Firefox seems to store the timezone value of the system at startup.
With Visual Studio it looks like you can turn the trick on its head. It seems that the Timezone is only read when you first start the debug process. So In my case, what I did was set the TimeZone to, for example, Eastern Standard Time. Start the Visual Studio debugger. I then changed the TimeZone to, for example, Pacific Standard time. The server at this point remained in the Eastern timezone, while my browser was in the Pacific timezone. Now I was able to test the client browser behavior just fine.
If you wanted to test a client in Japan, then just update your TimeZone and the browser will follow it. As long as you don't restart the debug process your server timezone will not change. Also just changing the time (as opposed to the timezone) did not work.
There is a lot of time zone extensions available to spoof in browser level. I am using currently
After adding click option of the extension and check
Once both done, Go to any website and open developer tools and check by executing below command
new Date().toLocaleTimeString()
Old question, but I had a similar issue and I'll throw my fix in anyways.
What I did was run my server in a virtual machine, set the network settings to bridged so that I'd be able to access the server from my host OS as the client easily.
I then changed time settings in the VM so that there was whatever difference I wanted between the client and server.
Maybe it will help someone. You can change time zone for Windows 10 using this steps:
Open Settings.
Click on Time & Language.
Click on Date & time.
Change time zone to your need.
P.s. According to the #Oscar Acevedo comment this answer is not quite correct. It's suitable for testing different time zones.
This an easies way I tried to chang time zone and test it for windows 7 ^
I use tzutil
tzutil /s "Eastern Standard Time"
and save it to suitable .bat file e.g Eastern_Standard_Time_zone.bat and use default_time_zone.bat conain your original system time zone to get it back after finishin tesing . this will change your time zone in blink .
reference
If you are into reproducibility, I suggest that you use an e2e environment, i.e. tooling that can automate browsers and allows to manipulate their time zone.
That way you won't have to fiddle around with the system time zone and you can add tests, that specifically do use different time zones, i.e. you can test your code in different time zones.
Two of the most recent popular libraries for browser automation, Puppeteer and Playwright explicitly allow setting the time zone. Using Playwright you get the ability to automate setting the time zone for all major evergreen browsers (Safari, Firefox and Chrome / ChromeEdge):
for Puppeteer you have to use page.emulateTimezone
for Playwright you have to use a newContext
You're probably better off leaving your computer timezone intact and changing your server settings to reflect a timezone ahead or behind of you. This is usually pretty easy to do depending on the server you're using.

Centos 6 Wrong timezone displaying on Web Page when pulling from server time

I'm currently having an issue with the wrong timezone displaying on a web page. I support a Linux environment for a small app development team. Currently we are testing a particular app. For test purposes we have a simple web page showing that the app is live and working. The page itself displays the project title and server time.
This issue is that the web page displays the incorrect timezone, however the time itself is correct.The text displayed is "The time on the server is April 5, 2018 7:18:04 AM CDT." For context I've included a screen shoot.
time zone issue
Nothing special going on here. As I said the time is technically correct, but it's displaying Central time when I need it to show Eastern, because the people using the app will be located in the Eastern timezone.
I support the environment itself and am not a developer. However, after speaking with them they ensure me that whatever method is being called is pulling from the server time. I've tested this successfully and am able to manually change the time on the server that it is hosted on, and the web page will reflect that.
Within the environment we are using CentOS 6. Based on my research the timezone information is handled by the file "localtime" within the "etc" directory. I've used several methods to alter this file.
I've tried the following command:
cp /usr/share/zoneinfo/Eastern /etc/localtime
I've also tried variations of the command. The server shows the correct time and timezone, but the timezone displayed on the web page never changes.
We have two servers to host apps. The interesting this is that apps that are hosted on the other server are being displayed correctly with the Eastern timezone. I've also tried simply taking the "localtime" file on the correct server, and copying it to the other server within the /etc/ directory. With each attempt doing a server restart.
I realize this is a simple issue, but after trying multiple methods with no success I thought I would seek assistance. Any help is appreciated.

Magento: Adding a new TimeZone

I need to add a new timezone to a Magento 1.7.0.2 site which can not be updated to a newer magento version (core files have been modified, which we all know should be avoided, but it's done already so no way to work around that). The timezone "America/Cancun" (which I use on other sites) is just not present on this install because it's a new timezone (magento 1.9.0.2 has it, for example). If I try to just change the value in the Database to "America/Cancun", the value that displays in the Magento admin is Australian time (which I guess is the default because the option I tried to enter does not exist).
Any ideas will be much appreciated.

Creating service on windows xp

I'm creating services on Windows XP.
I have to use a utility that we are using . The utility is making registration in the registry.
My question is that when I'm creating the service a folder name Enum is not created, which I saw was created for all other services.
Is it important ? For what I need it ?
Thanks
You should use the service APIs (CreateService) to create your service instead of manipulating the registry manually (or via your utility).
The format of the services registry has changed over the years and if you don't use the defined APIs, you may risk malfunctions (you're also going to require a reboot after the registry changes are made because the service controller has now way of knowing about your new service).
A common windows service doesn't need anything such as "Enum" Directory. It must be something specific in your applications. So if the directory wasn't created automatically, you need to write an installer for your service which creates this directory automatically, or create it manually.
You can use the command "instsrv" if you want to register a new service running under Windows XP.
Cheers
Tomas

where does asp and iis 6.0 get its date format

I've found a dilly of a pickle with a new web server. We have a new web server that is displaying dates differently than our old web servers.
We are running asp classic web pages on IIS 6.0 with windows server 2003.
We have logged in as an administrator and set the regional settings as appropriate and then applied the settings to current user and default user profile.
We then went into registry and update the appropriate formats under HKEY_USERS/.default/control panel/international.
Update the asp.net configuration for our websites to the correct code-page and locale.
Does anyone have other places that the application could be getting date formats from?
I know this isn't the 'proper' way to fix the issue. However, the application was written many years ago, getting something through planning/change control would be a pain, and is the only application running on the server. Thus it is okay to configure the server to cater to this single application. Besides it was driving me crazy that a new server that should be configured identically to an old server was not working.
It turns out that in addition to HKEY_USERS/*/Control Panel/international, there is a setting for non-unicode programs. It can be found under HKLM/system/currentcontrolset/control/nls/language/Default. Set that to the correct code page and it is golden.
On the other hand, if you prefer to not modify the registry directly, you can update all these values through the Regional settings from the control panel.
You can adjust the formats through the 'customize' button.
You can change the 'language for non-unicode programs' under advanced tab.
Just make sure that you check the 'apply to the default profile' at the bottom of the advanced tab.
I don't think the highest vote answer is right, though it's close.
I had to use regedit to change all the internationalization settings of HKU\S-1-5-19\Control Panel\International (NT Authority) and HKU\S-1-5-20\Control Panel\International (Network Service) to match the settings that were already in HKU\S-1-5-18\Control Panel\International (Local System).
This worked perfectly.
I modified all the settings I could see which were different, by hand.
I should think I only really needed to change the settings for S-1-5-20 (Network Service).
Go to Control Panel -> Regional And Language Options, set all options you need, then under 'Advanced' tab select settings for non-Unicode programs and check 'Apply all settings to the current account and to the default user profile.'. Press OK and restart server.
On Windows Server 2008 administrators have additional 'Administrative' tab. There press 'Copy to reserved accounts'.
Classic ASP Defaults to the Locale ID that was configured when the server was Setup. If you have access to the original server run the following code to get Locale ID it's operating under and verify that the new server is using the same.
<%=Session.LCID%>
If the Locale IDs are different and you cannot change it on the new server then you can add a line to the Session_OnStart sub in the global.asa for the application that assigns the correct Locale ID to Session.LCID.
Using an ASP page with the content:-
Response.Write GetLocale
Might be informative, it'll show you what locale VBScript thinks its using.
I've seen issues like this in the dim and distant past when using integrated security. The ASP caches the regional details from a user hive when it first needs to use them then continues to use those settings until the process dies. ASP gets these settings from the user hive associated with the user identity the code is currently running under. Most of the time that would be DEFAULT because the user doesn't have a profile on the system.
However if the user happens to have logged on interactively to the server they will have a profile and so their settings are used. Hence I've seen situations where the server appears to have intermitten problems with regional settings.
I can't recall if I've seen this on IIS6, I've definitely seen it on IIS5.
If you run your ASP application under a different account (not IUSR_Guest)
Login as that account, set date/time format to what you want and restart IIS.

Resources