date-conversion

Converting Gregorian date to Hijri date

这一生的挚爱 提交于 2019-11-28 06:58:35
How do you convert Gregorian dates to Islamic Hijri dates using JavaScript? 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; if(y==1582) { if(m>10) b = -10; if(m==10) { b = 0; if(day>4) b = -10; } } jd = Math.floor(365.25*(y+4716))

javascript - regular expression to validate date in mm/dd/yyyy format [duplicate]

怎甘沉沦 提交于 2019-11-28 05:18:18
问题 This question already has answers here : Regular Expression to match valid dates (15 answers) date formatting with/without Moment.js (4 answers) Closed 6 years ago . I'm not good at regular expression. I got code to validate dd/mm/yyyy format which also validates leap year, I tried to modify to get it work for mm/dd/yyyy, but they all failed. Can some one change it to validate mm/dd/yyyy format? Regular Expression: ^(((0[1-9]|[12]\d|3[01])/(0[13578]|1[02])/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d

How to convert a “HH:MM:SS” string to seconds with PHP?

故事扮演 提交于 2019-11-28 03:47:43
问题 Is there a native way of doing "HH:MM:SS" to seconds with PHP 5.3 rather than doing a split on the colon's and multipling out each section the relevant number to calculate the seconds? For example in Python you can do : string time = "00:01:05"; double seconds = TimeSpan.Parse(time).TotalSeconds; 回答1: The quick way: echo strtotime('01:00:00') - strtotime('TODAY'); // 3600 回答2: This should do the trick: list($hours,$mins,$secs) = explode(':',$time); $seconds = mktime($hours,$mins,$secs) -

How to get the integer value of day of week

故事扮演 提交于 2019-11-27 18:54:29
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 Use day1 = (int)ClockInfoFromSystem.DayOfWeek; int day = (int)DateTime.Now.DayOfWeek; First day of the week: Sunday (with a value of zero) If you want to set first day of the week to Monday with integer value 1 and Sunday with integer value 7 int day = ((int)DateTime.Now.DayOfWeek == 0) ? 7 : (int

Converting Numbers from Western Arabic Digits “1,2,3…” to Eastern Arabic Digits “١, ٢, ٣…”

怎甘沉沦 提交于 2019-11-27 15:25:44
问题 I need to convert date stored in database into Hijri and display the same in Arabic I used the Culture to convert the date which it does but it still display date as English numbers Example Gregorian Date = 19/01/2012 Its equivalent date in Hirji is 25/02/1433 Following code snippet converts but displays same as 25/02/1433 While i want it in Arabic numbers something like ٢٥/٠٢/٢٠١٢" string sDate DateTime dtt = Convert.ToDateTime("19/01/2012"); CultureInfo ci = new CultureInfo("ar-SA"); sDdate

Convert this string to timestamp PHP [duplicate]

醉酒当歌 提交于 2019-11-27 14:23:47
This question already has an answer here: Convert one date format into another in PHP 15 answers 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. 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::createFromFormat() instead: $dtime = DateTime::createFromFormat("d/m G:i", "13/10 15:00"); $timestamp = $dtime->getTimestamp();

converting gregorian to hijri date

偶尔善良 提交于 2019-11-27 12:53:55
I want to convert from Gregorian to Hijri(Islamic) date and I need a java class for this converting. I want to give it an Gregorian date in format of "yyyy/mm/dd" as string and it give me the Hijri date in the same format. can anyone help me? Jon Skeet Firstly, separate out the conversion part from the formatting/parsing part. You can deal with those easily later - and there are lots of questions on Stack Overflow about that. Personally I'd use Joda Time , which typically makes life much simpler. For example: import org.joda.time.Chronology; import org.joda.time.LocalDate; import org.joda.time

Go / golang time.Now().UnixNano() convert to milliseconds?

泪湿孤枕 提交于 2019-11-27 10:05:42
问题 How can I get Unix time in Go in milliseconds? I have the following function: func makeTimestamp() int64 { return time.Now().UnixNano() % 1e6 / 1e3 } I need less precision and only want milliseconds. 回答1: Just divide it: func makeTimestamp() int64 { return time.Now().UnixNano() / int64(time.Millisecond) } Here is an example that you can compile and run to see the output package main import ( "time" "fmt" ) func main() { a := makeTimestamp() fmt.Printf("%d \n", a) } func makeTimestamp() int64

Changing date format in R

你。 提交于 2019-11-27 07:07:41
I have some very simple data in R that needs to have its date format changed: date midpoint 1 31/08/2011 0.8378 2 31/07/2011 0.8457 3 30/06/2011 0.8147 4 31/05/2011 0.7970 5 30/04/2011 0.7877 6 31/03/2011 0.7411 7 28/02/2011 0.7624 8 31/01/2011 0.7665 9 31/12/2010 0.7500 10 30/11/2010 0.7734 11 31/10/2010 0.7511 12 30/09/2010 0.7263 13 31/08/2010 0.7158 14 31/07/2010 0.7110 15 30/06/2010 0.6921 16 31/05/2010 0.7005 17 30/04/2010 0.7113 18 31/03/2010 0.7027 19 28/02/2010 0.6973 20 31/01/2010 0.7260 21 31/12/2009 0.7154 22 30/11/2009 0.7287 23 31/10/2009 0.7375 Rather than %d/%m/%Y , I would

How to convert a string Date to long millseconds

假如想象 提交于 2019-11-27 01:54:53
I have a date inside a string, something like "12-December-2012". How can I convert this into milliseconds (long)? Jon Lin 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(); } SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); Date date = (Date)formatter.parse("12-December-2012"); long mills = date.getTime(); Take a look to SimpleDateFormat class that can parse a String and return a Date and