Changing ADUC Account expiration date via command saves wrong date - batch-file

I am trying to make a simple batch file to change a user's ADUC expiration to a specified date.
Using the below command the date always appears in ADUC as one day prior to what I set:
net user myname /expires:09/17/13 /domain
In ADUC, the date will be: 09/16/2013. No matter what, the date that appears in ADUC is one day before the day I set.
The documentation I found for this indicates
Note that the account expires at the beginning of the specified date.
So does this mean, If i wanted the account to be expired today, I would send the command for today and ADUC would interpret that as yesterday?
Thanks in advance, I just want to get this right.

As a wild guess, since you're UTC-savvy - is the date UTC date, so 130917T0000Z=130916T1900 local?

Related

Alexa AMAZON.DATE slot default to past dates

I am using the AMAZON.DATE slot and I would like it to default to past dates.
For example, if a user says Monday I would like it to automatically select last Monday rather than next Monday.
In the documentation it confirms that it defaults to 'on or after the current date':
"Utterances that map to a specific date (such as "today", "now", or
"november twenty-fifth") convert to a complete date: 2015-11-25. Note
that this defaults to dates on or after the current date (see below
for more examples)."
For my application there is no way a future date would make sense so it wouldn't be too difficult to manually program this in but I just wondered if there was any other way of doing it?
No, you cannot change the behavior of built in slots, so if Alexa resolves user's answer as a date - before passing it to your further processing just subtract 7 from resolved value. It will give you the date in the past.

Is it possible to specify time zone for DB data source in PHPStorm?

I have UTC time zone set in my PostgreSQL and SELECT NOW() shows me the right date in psql console.
I use PHPStorm for development and its database console for accessing my database, but it uses different time zone (Europe/Moscow, which is the time zone of my Mac), and SELECT NOW() shows me the time in this time zone (and by the way, the date is wrong, because the Europe/Moscow time zone recently changed its offset to +3 from +4).
I have not found any information on how to tell PHPStorm to use the time zone configured in postgresql.conf instead of system's time zone. Is it possible?
verify your timezone with query
SELECT * FROM pg_timezone_names
now add phpstorm.vmoptions the config off timezone
-Duser.timezone=posix/America/Sao_Paulo
Apply changes, disconect, synchronize and verify whithselect now()
Well, I've found a solution, but it will affect every time-specific behavior in IDE, e.g. console logs will show datetime in UTC.
The idea is to pass a timezone to VM options. For that we need to modify a file and restart IDE.
For Mac OS X for the latest version of PHPStorm:
cp /Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions ~/Library/Preferences/PhpStorm2016.1/
Then add -Duser.timezone=UTC to the file, so that it looks something like that:
-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-Duser.timezone=UTC
After phpstorm.vmoptions file modification with -Duser.timezone=UTC line I've seen correct return only from NOW() function but incorrect from the queries to a table like SELECT timestamp FROM ...
Only adding a variable timezoneAsRegion with false value to Advanced tab of connection without any phpstorm.vmoptions changes helped me to return correct timezone from the table.
Documentation link: https://www.jetbrains.com/help/phpstorm/2016.1/data-sources-and-drivers-dialog.html#advancedTab

how to convert a date into both European and American time zones in the same sql server report rdl?

I have a report which takes timezone as input parameter, picks date from a table and converts this date to the user selected time zone.
User can select timezones from a dropdown which contains both US and European timezones.
When I select the European timezones, I see #Error in the date cell in the report.
I have no clue what so ever about reports and I need to fix this error in the inherited report.
The conversion is done by a little VB script embedded in the report.
Shared Function ConvertTimeZone(ByVal systemDate As Date, ByVal timeZoneId As String) As Date
Dim timeZoneInfo As TimeZoneInfo
timeZoneInfo = timeZoneInfo.FindSystemTimeZoneById(timeZoneId)
Return (timeZoneInfo.ConvertTimeFromUtc(systemDate, timeZoneInfo))
End Function
If EET is passed as timezone id - I see #Error in the date cell.
Could this be because both European and US timezones cant be used together?
Can someone guide me through this issue?
If EET is passed as timezone id - I see #Error in the date cell
That's because "EET" is not a valid time zone identifier. You can see all of the valid identifiers by examining the output from TimeZoneInfo.GetSystemTimeZones(), which returns a collection of TimeZoneInfo objects. Each one has an Id and a DisplayName. The Id is what needs to be passed in your timeZoneId parameter, while the DisplayName can be shown to your end user in the dropdown list. (You probably don't want to use the StandardName or DaylightName properties, unless you have a specific reason to.)
You are probably looking for the identifier "E. Europe Standard Time". Don't get confused by the name, it's the correct identifier covering both Eastern European Time (EET) and Eastern European Summer Time (EEST). The Microsoft time zone database is a bit strange in that way.
You can also see the valid time zones by running tzutil /l on the command line. Each time zone will emit two lines, where the top line is the display name, and the bottom line is the ID.
EDIT
Another suggestion, VB is case insensitive, but you have your variable named timeZoneInfo, which is the same as the class TimeZoneInfo. This would normally work ok, but I see that you have the lower case form on the ConvertTimeFromUtc method, and it should be upper case. Since this is VBScript, you might not be seeing this error until runtime. Try changing the case, or just use a different variable name so you don't get them confused.
Shared Function ConvertTimeZone(ByVal systemDate As Date, ByVal timeZoneId As String) As Date
Dim tzi As TimeZoneInfo
tzi = timeZoneInfo.FindSystemTimeZoneById(timeZoneId)
Return (TimeZoneInfo.ConvertTimeFromUtc(systemDate, tzi))
End Function
Here's another idea you can check if that doesn't fix it. The input systemDate should have come from your data, which should have DateTimeKind.Unspecified when you examine it's .Kind property. If for some reason you are taking it from DateTime.Now instead, then it would have a DateTimeKind.Local, which would through an exception.
If you still get the error, please see if you can find out what exception or error is actually occurring. Check log files, event viewer, etc.

Javascript time saved incorrectly in sql server table

new Date(moment().year(), moment().month(), moment().day(), vm.newHearing().HearingTime().split(":")[0], vm.newHearing().HearingTime().split(":")[1]).toLocaleString()
The client side value for a date column is 11/5/2013 10:15:00 AM. The time is selected from HTML5 time input control.
When I check in database after saving the entity, it shows me incorrect time value:
11/5/2013 3:15:00 PM
It appears that you are using moment.js, which is fine except you aren't using it properly
Try this instead:
moment(vm.newHearing().HearingTime(), "HH:mm").toISOString()
That will pass the selected time, on the current day, from the user's local time zone, converted to UTC time and in ISO format.
Now that might not be exactly what you want to do. Depending on your requirements, you might instead want this:
moment.utc(vm.newHearing().HearingTime(), "HH:mm").toISOString()
Which is almost the same thing except that it assumes the input time is already in UTC.
Or you might want this:
moment(vm.newHearing().HearingTime(), "HH:mm").format("YYYY-MM-DDTHH:mm:ss")
This one doesn't try to convert to UTC at all.
For all choices, I emit the date string in ISO8601 format. Since you are sending it back to the server, this is the best choice. When you used toLocaleString, that generates a format that is appropriat for display only.

What time zone does a scheduled job use for Preferred Start Time

We have a scheduled job that runs on the 1st of each month with a Preferred Start Time of 1am. The job was scheduled using the Salesforce interface (Develop | Apex Classes | Schedule Apex). When it runs, it sets a month field for records based on the System date (System.today();). Occasionally, the month is set wrongly, and I suspect it's due to the date variable set to the System date.
If I set the job to run at 1am, logged in as my User (with a time-zone set to CDT), using the interface, what value would be returned by System.today()? Would the current CDT date be returned, or the GMT date?
Scheduled jobs run as "system", but I think there's still a user context, which means Date.today() or System.today() would be in CDT.
Update:
Just tested this and DateTime.now() returns GMT values.
Another update:
The docs say Date.today() returns the date in the current user's time zone. Based on the test below, the system knows who the user is, and it knows the user's time zone, so Date.today() would be the current date in the user's time zone. I confirmed this by setting my time zone to +10, and the system returned 2012-03-15 for the date.
// Brisbane +10 time zone
global void execute(SchedulableContext SC) {
System.debug(DateTime.now()); // 2012-03-14 19:24:39
System.debug(DateTime.now().formatLong()); // 3/15/2012 5:24:39 AM AEST
System.debug(Date.today()); // 2012-03-15 00:00:00
System.debug(UserInfo.getUserName()); // dev1#jeremyross.org
}
From the APEX dev guide:
The System.Schedule method uses the user's timezone for the basis of all schedules.

Resources