I have an epoch 1362873600 and I only care about the date portion, not the time.
My goal is to get:
03/10/13
I'm doing the following:
var dateFormatter = new google.visualization.DateFormat({formatType: 'short'});
dateFormatter.formatValue(epochValue);
I've tried with epochValue as a string and as an int.
Both yield: Object 1362873600 has no method 'getTimezoneOffset'
Is there perhaps an option I can use to ignore the timezone part? What is it that formatValue is expecting that would have this getTimezoneOffset method? The documentation just says 'value'.
It looks like formatValue is expecting a Date object. You can construct one if you know the epoch with new Date(epoch). After you create that object, you should be able to pass it to formatValue and get the value you're expecting.
var dateFormatter = new google.visualization.DateFormat({formatType: 'short'});
var result = dateFormatter.formatValue(new Date(epochValue));
Related
I am creating a google sheet that feeds from a form. I want to capture the timestamp in a separate cell when another cell is changed. I can get it to display the time now but I need it to be in military time.
var timezone = "GMT-4"
var timestamp_format = "hh:mm:ss"; // Timestamp Format.
I expect the output to say 13:15:55, but the actual is 1:15:55.
Google's App Script uses the standard JavaScript Date object when returning forms. Here is how to get what you want from a Date object.
var resultFromForm = ...
var time = resultFromForm.toTimeString().substring(0, 8);
you can just change internal formatting like:
Rails 4.1
I'm am trying to add a date attribute to an ActiveRecord object by handing it a string and I'm getting some strange results:
t = MyClass.new
t.StartDate = "1/11/2015" #date is loaded as expected
t.StartDate = "1/12/2015" #date is loaded as expected
t.StartDate = "1/13/2015" #ArgumentError: argument out of range
The same appears to hold true for any day of the month > 12. What am I missing here? Yes, I could parse the string into a Date object (and I've been able to do this successfully with the same problem dates as strings), but why does my method work for some valid dates and not others?
Your dates are formatted with day/month/year when your trying to use it like month/day/year
This is why you can't go further than 12 because 12 is representing the month
While querying data from a database I receive the hours a process is started and ended in two separate string fields for example start = "1100" and end = "+0200" which indicate it's hours of operation are from 11am-2am. What is the proper way to represent this in swift so that I can determine the amount of time left from the current time to the end time of the process.
EDIT:
I found an interesting way using the date formatter if I remove any possible prefix of + and use the below code it seems to work correctly; however, the date is not set is their a work around?
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "HHmm"
let date = dateFormatter.dateFromString("1340")
You can create NSDate from components using NSCalendar.currentCalendar().dateWithEra (there are other similar functions, look up NSCalendar for details). You will need to add some logic to determine if the 2AM is today or tomorrow etc.
Then you can compare two NSDate dates. To determine time left to the end you would probably use NSDate method timeIntervalSinceDate. You can also use NSDateComponentsFormatter to get the remaining time nicely formatted.
I have variable of type string now i have to know the given input in variable is date.
i am using if (DateTime.TryParse(count,out dDate)) for that but it not work properly.
Here count is my string variable;
I have the date variable which is in string format. I need to convert this to numeric or date format. How can I do this?
Example:
var1
2010/07/09
2010/07/16
Thanks,
Tanuvi
If you read in the date value as a string, you can use Transform > Date and Time Wizard to convert it to an SPSS date variable. Although date variables look like dates in various formats, they are actually represented as the number of seconds since 1582 and can consist of calendar and time information.