date-conversion

Converting Gregorian date to Hijri date

会有一股神秘感。 提交于 2019-11-27 01:38:35
问题 How do you convert Gregorian dates to Islamic Hijri dates using JavaScript? 回答1: function gmod(n,m){ return ((n%m)+m)%m; } function kuwaiticalendar(adjust){ var today = new Date(); if(adjust) { adjustmili = 1000*60*60*24*adjust; todaymili = today.getTime()+adjustmili; today = new Date(todaymili); } day = today.getDate(); month = today.getMonth(); year = today.getFullYear(); m = month+1; y = year; if(m<3) { y -= 1; m += 12; } a = Math.floor(y/100.); b = 2-a+Math.floor(a/4.); if(y<1583) b = 0;

Convert PHP date into javascript date format

前提是你 提交于 2019-11-26 23:13:05
问题 I have a PHP script that outputs an array of data. This is then transformed into JSON using the json_encode() function. My issue is I have a date within my array and its is not in the correct javascript format. How can I convert this within PHP so it is? $newticket['ThreadID'] = $addticket; $newticket['Subject'] = $subject; //$newticket['DateCreated'] = date('d-m-Y G:H'); Instead of the above fo rthe date I need the equivilant of the javascript function new Date() When I output the above I

Convert this string to timestamp PHP [duplicate]

筅森魡賤 提交于 2019-11-26 18:24:04
问题 This question already has answers here : Convert one date format into another in PHP (15 answers) Closed 6 years ago . I have this string: "13/10 15:00" and I would like to convert it to timestamp but when I do this: $timestamp = strtotime("13/10 15:00"); It returns an empty value. 回答1: In your code strtotime() is attempting to convert 13/10 as the tenth day of the 13th month, which returns an error. If you want to parse a date string with a custom format, it's better to use DateTime:

How to get the integer value of day of week

匆匆过客 提交于 2019-11-26 15:51:49
问题 How do I get the day of a week in integer format? I know ToString will return only a string. DateTime ClockInfoFromSystem = DateTime.Now; int day1; string day2; day1= ClockInfoFromSystem.DayOfWeek.ToString(); /// it is not working day2= ClockInfoFromSystem.DayOfWeek.ToString(); /// it gives me string 回答1: Use day1 = (int)ClockInfoFromSystem.DayOfWeek; 回答2: int day = (int)DateTime.Now.DayOfWeek; First day of the week: Sunday (with a value of zero) 回答3: If you want to set first day of the week

How to remove the time portion of a datetime value (SQL Server)?

大兔子大兔子 提交于 2019-11-26 12:06:37
Here's what I use: SELECT CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME) I'm thinking there may be a better and more elegant way. Requirements: It has to be as fast as possible (the less casting, the better). The final result has to be a datetime type, not a string. SQL Server 2008 and up In SQL Server 2008 and up, of course the fastest way is Convert(date, @date) . This can be cast back to a datetime or datetime2 if necessary. What Is Really Best In SQL Server 2005 and Older? I've seen inconsistent claims about what's fastest for truncating the time from a date in SQL Server, and some

How to convert a string Date to long millseconds

孤者浪人 提交于 2019-11-26 09:49:13
问题 I have a date inside a string, something like \"12-December-2012\". How can I convert this into milliseconds (long)? 回答1: Using SimpleDateFormat String string_date = "12-December-2012"; SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy"); try { Date d = f.parse(string_date); long milliseconds = d.getTime(); } catch (ParseException e) { e.printStackTrace(); } 回答2: SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); Date date = (Date)formatter.parse("12-December-2012"); long

Converting date in Year.decimal form in R

不想你离开。 提交于 2019-11-26 08:34:54
问题 I have a ts column that saves years in decimal format ie 1988.0 1988.25 1988.5 1988.75 and so on. I need to export it to a .csv file with the date in a \"DD-MM-YYYY\" format. How do I do this? 回答1: The lubridate package has a function, date_decimal that you can use for this. x <- c(1988.0, 1988.25, 1988.5, 1988.75) library(lubridate) (f <- format(date_decimal(x), "%d-%m-%Y")) # [1] "01-01-1988" "01-04-1988" "02-07-1988" "01-10-1988" Then you can write it to a csv with write.csv(f, "afilename

Date and time conversion to some other Timezone in java

坚强是说给别人听的谎言 提交于 2019-11-26 03:23:37
问题 i have written this code to convert the current system date and time to some other timezone. I am not getting any error but i am not getting my output as expected. Like if i execute my program at a particular time.. My output is :: The current time in India is :: Fri Feb 24 16:09:23 IST 2012 The date and time in :: Central Standard Time is :: Sat Feb 25 03:39:23 IST 2012 And the actual Time according to CST time zone is :: Friday, 24 February 4:39:16 a.m(GMT - 6:00) So there\'s some time gap

Convert String Date to String date different format [duplicate]

那年仲夏 提交于 2019-11-26 02:14:50
问题 This question already has an answer here: Converting date-string to a different format 5 answers I am new to Java. Postgres db contain date format is yyyy-MM-dd . I need to convert to dd-MM-yyyy . I have tried this, but wrong result is display public static void main(String[] args) throws ParseException { String strDate = \"2013-02-21\"; DateFormat formatter = new SimpleDateFormat(\"dd-MM-yyyy\"); Date da = (Date)formatter.parse(strDate); System.out.println(\"==Date is ==\" + da); String

Convert one date format into another in PHP

我怕爱的太早我们不能终老 提交于 2019-11-25 22:50:39
问题 Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date(\'y-m-d-h-i-s\'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date(\'Y-m-d H:i:s\', $middle); // returns 1970-01-01 00:00:00 But I\'d of course like it to return a current date rather than the crack \'o dawn. What am I doing wrong? 回答1: The second parameter to date() needs to be a proper timestamp (seconds since January 1, 1970). You are passing a