Social Engine time display format - socialengine

I'm working on a Events module in SE4, and would like to display time/date in some particular format. This is the code i use now, for displaying event start time:
echo $this->locale()->toTime($event->starttime); and this code displays output 11.00 which is okay, but my question is: how to format this output?
Let's say I need output 11:00, is there a way to format it that way?

Try this
$this->locale()->toTime($event->starttime,array('format'=>'h:m'))

Related

Best way to format currency in Yii gridview with no decimals

Can Yii formatCurrency be used to format a currency value in cGridView with zero decimal places?
My current code is:
Yii::app()->locale->numberFormatter->'.'formatCurrency($data["'.$columnName.'"],Yii::app()->params->currency)
Which results in:
$50,000.00
And I want the result to be:
$50,000
Same problem discussed in Yii forum. Here I added some points. Please check the relevant link.
This is due to your locale currency settings. Go and check your YII framework folder/i18n/data you will fix the problem there... Find your locale and fix it.
In ii18n/Cnumberformatter.php
change line 162
$value=round($value,$format['maxDecimalDigits']);
to
$value=number_format($value,$format['maxDecimalDigits'],'.','');
refer this forum.
http://www.yiiframework.com/forum/index.php/topic/21002-formatcurrency-broken/

Selecting a datetime range in YII input form

Here is the problem.
I have to create a submission form on my Yii-based website. The form requires to enter a datetime range.For that I am using "jui datetimepicker" third-party Yii extension.
http://www.yiiframework.com/extension/datetimepicker/
I use two date fields with this extension pertaining to start and end time respectively. So, what I want to achieve is be able to restrict the start datetime only to time in the future (neither past dates nor time should be selected) and the end time itself should be restricted to the maximum of three hours following the start time.
EXAMPLE: a user wants to schedule an event. They choose a date and time, which are of course in the future. Let's say they choose March 15, 13 O'clock as the start time in the start time field. Once they are done and move to the next field ("end time"), the respective datetimepicker restricts the range of time from March 15, 13:00 to March 15, 16:00.
Hence the second datetimepicker should be dynamically updated depending on the input of the first one.
It's possible o specify date range in the datetimepicker starting from the current date, but there is nothing like that for the time selection, so a user still can select time which has already passed.
It's not that I want to solve this problem with this extention, if anybody has any suggestions about YII solutions allowing to specify a datetime range in the most clean and effective way - it would be much appreciated.
You should use the edaterangepicker extension instead.
Given the API for the jquery timepicker addon. you should add the following to your widget call (along side 'model','attribute', etc)
'options'=>array(
'minDateTime'=>'<start dateTime here>',
'onSelect'=>'<JS function to run>'
)
The function you run on the "onSelect" event should dynamically set the minDateTime for the second dateTime input field, for ex:
function (selectedDateTime){
<EndDatePickerElement>.datetimepicker('option', 'minDateTime', <start dateTime here using selectedDateTime> );
}
There are more examples on the link provided earlier if you need to make it even more precise (like say if you wanted the starting date to be pushed back by the amount of time the user was on the page rather than it being set when the page was loaded. etc...)

how to check current system date format?

How can i check the system date format? Tried with the code below, but when i change my system's date format to another date format to test the code, it's still showing the date format before changed!
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern()
Ok. I managed to find the solution, the 'CurrentCulture' has to be 'CurrentUICulture', instead of CurrentCulture. Which is as below:
System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern()

How to change Unix Timestamp to Human Date in rails 3

I've seen a couple of posts doing the reverse for mysql, but I'm looking for a way to change a unix timestamp to a human readable date (ideally one I can change the format of) and I haven't been able to find anything so far.
I'm storing a date pulled from an XML feed, via NokoGiri (in Rails 3.1.1) as part of a hash:
'date' => i.xpath('#unix-timestamp')
which gets the number fine, but how the devil do you make this DD-MM-YYYY to be put in one of my views?
I've tried Time.at( (i.xpath('#unix-timestamp') ) to no avail; I just get the error 'can't convert Nokogiri::XML::NodeSet into an exact number' and now I've hit a wall
Much gratitude for any help!
Time.at is definitely a call that should work to convert from epoch time to a ruby Time object (see here for an example). So it seems like you need to work on converting your XML result into something more usable. I think you want to try using NodeSet#text to get a string output, then converting that to an integer:
Time.at(i.xpath('#unix-timestamp').text.to_i)
There's a decent but basic tutorial for NokoGiri in the Engineyard blog
You can use like : DateTime.strptime("1373210218",'%s')
and also Time.at(1373210218).strftime("%B %e, %Y at %I:%M %p")

Using drupal profile date in vb.net

I am using drupal databas ein one of my application. Drupal profile saves date in following format:
a:3:{s:5:"month";s:1:"2";s:3:"day";s:2:"18";s:4:"year";s:4:"1995";}
I can read this with data reader but how to convert in a proper display like DD/MM/YYYY or YYYY/MM/DD
Well, you can kind of see the values for month, day and year in that zany string. Presumably there is something in VB that can help you parse and glue together the string as you need it?
You might look into how PHP's unserialize() works, that will reformat the string to a more usable array.
Most of all, dont use profile, use content_profile and cck. Problem solved. Unserializing PHP serialization can get a bit hairy.