i am using the followin expression to retrieve a formatted current timstamp:
<xsl:value-of select="format-dateTime(current-dateTime(),
'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]')"/>
Generally it is working, just wondering if UTC timezone is returned? What I need though is CET. Is there any possbility to have CET instead of UTC returned? If so, how is this accomplished?
Thank you for your advice!
Related
I have a server that rejects a triple using the UTC offset syntax:
rtc_cm:due "2020-09-08T14:30:00+00:00"^^xsd:dateTime (Turtle)
but succeeds using the Z suffix:
rtc_cm:due "2020-09-08T14:30:00Z"^^xsd:dateTime (Turtle)
Is there a way to configure the Python rdflib serializer to prefer the Z suffix for UTC dates.
I noticed that rdflib.util.date_time() seems to do that, but the serializer does not, at least by default.
If you're using timezones, you need to use the literal xsd:dateTimeStamp.
See https://www.w3.org/TR/xmlschema11-2/#dateTimeStamp
I have a a checkin:datetime field in rails and is using the default utc.
But the issue is that when the user submits the form the checkin date is coming with his local timezone info. So rails will automatically convert this to utc and depending on the difference with his timezone and utc there might be an off of one day.
So how can I change the date to utc without changing values?
Update
This is the only code I use for saving to database.(the utc conversion is done by activerecord(i think) if the passed in value is not utc)
reservation=current_user.reservations.create(reservation_params)
reservation.save
I have found a way to do that. It is not direct conversion as I expected but it works. I changed the form input field to sent a string with just the date and time(without utc).
eg: 2016-07-13 00:00:00
Then in my controller before saving I used below code to parse it to utc.
reservation.check_in= Time.zone.parse(value_from_view)
example:
reservation.check_in= Time.zone.parse('2016-07-13 00:00:00')
This returns Wed, 13 Jul 2016 00:00:00 UTC +00:00 as expected.
I have ann app that has a start_date and an end_date that is currently in the format Thu, 23 Apr 2015 17:00:00 UTC +00:00 and the field type is datetime.
I am needing to convert it into this YYYY-MM-DDThh:mm:ssZ for the Eventbrite API but I am having little luck.
I have tried iso = Time.iso8601(start_date) but I get the following error TypeError: no implicit conversion of ActiveSupport::TimeWithZone into String
Anyone able to point me in the right direction it would be very much appreciated.
try following:
start_date.iso8601
output
=> "2015-05-06T15:53:51+05:00"
I have this date from twitter, this represents the exact date the tweet is published,
Sun, 01 Jul 2012 19:05:54 +0000
what I want is to make its format into MM/DD HH:MM, tried to look for php date formats but couldn't find a way to make it look exactly the way I want it to be. Can someone please help? Thanks.
print date('m/d h:i',strtotime('Sun, 01 Jul 2012 19:05:54 +0000'));
The date function for php is a good place to find all sorts of information on this.
This would be pretty simple to search and figure it out. You are looking for a date... ahh, date, that is a php function. When you look that up you will see that it takes some params, a format and a time stamp. Well... You do not have a time stamp you have a string. how do i convert a string to time? Wait, there is a strtotime function in php. There you have it... run the date function in php with the way you want the date to look and then convert the string to timestamp with strtotime
<?php
date_default_timezone_set("UTC");
$string = "Sun, 01 Jul 2012 19:05:54 +0000";
$timestamp = strtotime($string);
print "Date is " . date("m/d H:i", $timestamp) . "\n";
?>
You may have to change timezone, and/or add/subtract seconds or use local time functions to convert between TZ's.
In Rails, I see I have a few options to parse a date and a date-time. What is the best practice for parsing dates for the sole purpose of persisting them into the DB via ActiveRecord? And why?
Time.zone.parse(...)
Time.parse(...)
DateTime.parse(...)
Go with Time.zone.parse if you just want to write into ActiveRecord.
DateTime should be avoided. If you're handling dates, you should use Date.parse instead.
Beyond that, it depends on whether the input comes with timezone information, what the current timezone is set to, and whether you want timezones in your data.
Time.zone.parse will return an ActiveSupport::TimeWithZone, defaulting to UTC.
> Time.zone.parse("12:30")
=> Thu, 10 May 2012 12:30:00 UTC +00:00
Time.parse will return a Time, with a zone if it's specified in the input, or the local TZ.
> Time.parse("12:30")
=> 2012-05-09 12:30:00 -0700
For a more detailed explanation of Ruby time comparisons and precision, read this blog post:
http://blog.solanolabs.com/rails-time-comparisons-devil-details-etc/
Times that are automatically set by ActiveRecord (e.g. created_at and updated_at) come back as ActiveSupport::TimeWithZone instances.
According to the documentation, ActiveSupport::TimeWithZone and Time have the same API, so Time is what I would use.
On an unrelated note, there are methods to_time and to_datetime that you can call on strings:
"2012-05-09".to_time # => 2012-05-09 00:00:00 UTC
"2012-05-09".to_datetime # => Wed, 09 May 2012 00:00:00 +0000