date-formatting

Making a PHP/MySQL Timestamp look more attractive

一笑奈何 提交于 2019-12-06 14:35:26
问题 So basically, I'm currently selecting a Timestamp from my MySQL database. In the database, the timestamp looks like so: 2010-06-30 12:36:08 Obviously for a webapp, that's not very attractive for users to view. So, using some CodeIgniter functions, I made it look a bit nicer. <h4 class="timestamp"> <?php // Quickly calculate the timespan $post_date = mysql_to_unix($row->date); $now = time(); echo timespan($post_date, $now);?> ago </h4> If you don't do CodeIgniter, everything's standard PHP

Have Custom formatter for date field in JQGrid

强颜欢笑 提交于 2019-12-06 11:58:59
I want to diplay date on grid as N/A incase it is NULL in the database, or else in normal date format. At present I have this code: name: 'Handshake_Actual_Date', index: 'Handshake_Actual_Date', search: false, editable:true, align: "left", width: 75, formatter: "date", formatoptions: {newformat:"m/d/Y" }, editoptions: { size: 20, dataInit: function (el) { $(el).datepicker({ dateFormat: 'mm/d/yy' }); }, defaultValue: function () { var currentTime = new Date(); var month = parseInt(currentTime.getMonth() + 1); month = month <= 9 ? "0" + month : month; var day = currentTime.getDate(); day = day <

D3 time and date histogram

蹲街弑〆低调 提交于 2019-12-06 10:31:07
问题 I'm attempting to make a histogram using primarily time and date data, provided in a json file (along with other info) in this format: 2014-03-01 00:18:00. I've looked at http://bl.ocks.org/mbostock/3048450 as an example, but I haven't managed to crack it. The key part seems to be this: var data = d3.layout.histogram() .bins(x.ticks(20)) (dataset.timestamp); When I view my code in the browser it gives "TypeError: data is undefined", and refers to d3.v3.js line 5878. Assuming I fix that error,

am/pm strings not localized/translated when using DateFormat

不想你离开。 提交于 2019-12-06 06:12:42
When my app loads, I get device's settings in order to display dates/times according to user's locale. As seen on the image below, the pattern is correct, but the am/pm marker is not translated to the corresponding language (in this case language is Greek, local is "el_GR"). Is there a way to fix that? "am/pm" should be automatically translated to "πμ/μμ" public static final DateFormat USER_DF_TIME = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()); kouretinho After further investigation, I found a similar bug for Java 6, "Swedish localization has

Java convert millisecond timestamp to date with respect to given timezone

时光毁灭记忆、已成空白 提交于 2019-12-06 05:51:28
I have seen many resources on this but one thing I cant get is when converting the millisecond timestamp, how I add a corresponding time zone, during the conversion process. Date date = new Date(Long.valueOf(dateInMil*1000L); SimpleDateFormat myDate = new SimpleDateFormat("EEE, MMM d, ''yy"); String formatted = myDate.format(date); Now if I have a time zone/offset in string formate i.e. "-04:00" or "+2:00" how to apply it to the above so I can get the proper date ? I was doing a similar thing in my previous project.You can use setTimeZone method of SimpleDateFormat class. Something like this :

Excel VBA - Date Format Conversion

巧了我就是萌 提交于 2019-12-06 05:37:28
I have come across a challenging task which I am not able to solve using many workarounds. In one column I have dates, the date can be in following three formats: 1) Simple dd/mm/yy 2) dd/mm/yy but may have words "before,after or about" around it. Any one of it and we just need to delete those words in this case. 3) Date in a numeric format. A long decimal values like 1382923.2323 but actually I can get a date from it after conversion. The file is uploaded here. Date_format_macro_link I wrote the following code but it's giving wrong results. Sub FormatDates_Mine() ManualSheet.Activate

Order dataframe chronologically based on dates which are formatted %d/%m/%Y

妖精的绣舞 提交于 2019-12-05 22:40:57
问题 I have some data that has to be formatted as (%d/%m/%Y). The data is out of chronological order because it is sorted by the first number which is the day, not the month. I'm hoping I can specify to order or reorder that I want the sorting to happen differently. I'm just not sure how to do this. Here is some date data to be ordered: date 1/1/2009 1/1/2010 1/1/2011 5/4/2009 5/4/2011 10/2/2009 10/3/2011 15/9/2010 15/3/2009 31/12/2011 31/7/2009 Thanks for any suggestions. 回答1: When order by

excel vba - How to get the Day Name of Date?

雨燕双飞 提交于 2019-12-05 20:03:39
I have a small code that gets the Day Name of the Dates listed in Excel. But the problem is, it's not getting the right Day Name(e.g. Tuesday). For Example: sDayName = Format(Day(11/1/2016), "dddd") Then the output produces an incorrect Day Name which is: sDayName = "Sunday" when it's supposed to be "Tuesday". Thanks for the help guys. For your specific request, assuming your date string is formatted as your regional setings: sDayName = Format("11/01/2016", "dddd") If you want the weekday for today: sDayName = Format(Date, "dddd") If you want the weekday for any date in any regional settings

SQL date conversion results to “invalid number format model parameter.”

穿精又带淫゛_ 提交于 2019-12-05 18:11:55
I have to select some data from Oracle 11g database, but I can't seem to figure out why following select query is failing: SELECT INFO_ID, INFO_DETAIL, IMPORTANT_FLG, DELETE_FLG, CREATE_TIME, DISPLAY_ORDER FROM TABLE_NAME WHERE TO_DATE(TO_CHAR(CREATE_TIME, 'YYYY/MM/DD'), 'YYYY/MM/DD') BETWEEN TO_DATE(TO_CHAR(:fromDate, 'YYYY/MM/DD'), 'YYYY/MM/DD') AND TO_DATE(TO_CHAR(:toDate, 'YYYY/MM/DD'), 'YYYY/MM/DD') ORDER BY IMPORTANT_FLG DESC NULLS LAST , DISPLAY_ORDER ASC NULLS LAST, CREATE_TIME DESC, INFO_ID ASC The query is failing with following error message: ORA-01481: invalid number format model

Convert Date Formatting Codes to date

你离开我真会死。 提交于 2019-12-05 15:18:29
The user is supposed to enter date in format: %m %d %Y What I need to do is convert the date to: 11 11 2013 ( which is today`s date). I have not worked much with dates. Is there some method that does this conversion out of the box? I looked through DateTime options but couldn't find what I need. Edit: From the answers received it seems that it is not very clear what I am asking. In our software the user can insert dates in format like this: http://ellislab.com/expressionengine/user-guide/templates/date_variable_formatting.html I am trying to parse this user input and return the today date. So