date-conversion

How can I convert a date in Epoch to “Y-m-d H:i:s” in Javascript?

醉酒当歌 提交于 2020-01-21 02:39:09
问题 How can I convert following date in epoch: 1293683278 to following readable date: 2010-06-23 09:57:58 using Javascript? Thanks! 回答1: var timestamp = 1293683278; var date = new Date(timestamp * 1000); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hours = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); console.log(year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds); See js Date docs for

iOS vs Android: different dates displayed for the same program

空扰寡人 提交于 2020-01-16 05:10:26
问题 I have a javascript code: newDate: function(days) { var newDate = new Date( parseInt(startDate) + 1*1000*3600); var date = newDate .getDate(); return date ; }, Seems like this is the part of the program that produces different results on Android and iOS. All the rest data is the same. How can it produce different results on Android vs iOS? 回答1: The Date constructor is only consistent cross-browser for the following Date formats: "2010" "2010-06" "2010-06-09" "2010-06-09T15:20:00Z" "2010-06

Days since 1900

喜夏-厌秋 提交于 2020-01-15 02:54:25
问题 I'm using data from Excel2007 as parsed by PHPExcel, and dates come out as days since 1900. How can I convert to string of YYYY-MM-DD (or anything similar)? 回答1: Or use $phpDate = PHPExcel_Shared_Date::ExcelToPHP($cell->getCalculatedValue()); to convert an Excel/PHPExcel date to a PHP date/timestamp, and then use standard PHP date() function for formatting 回答2: Something like this, should do the trick: PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), 'YYYY-MM-DD');

Convert From Hijri to Georgian date in ASP & C#?

可紊 提交于 2020-01-02 07:14:14
问题 I have two text boxes, One in Hijri Date which I am inserting date in this text box using the calender extender. What I want is that upon selection of date (Hijri Date), the Georgian text box will filled with converted Georgian date using C#. Does anyone has code for changing the hijri date to georgian date? 回答1: You can simply convert between Hijri and Gregorian using the built in CultureInfo class Imports System.Globalization Private Sub Convert_From_Hijri_To_Gregorian(ByVal sender As

Parsing non-standard date format in Excel cell

送分小仙女□ 提交于 2019-12-31 05:18:12
问题 I want to convert dates formatted like "March 30th 2017, 05:00:00.000" to an excel date value? What's the most elegant solution I can do this with using a cell-formula and not VBA? 回答1: This will do the standard "rd","th","st","nd" =--(LEFT(A1,MIN(FIND({"rd","th","st","nd"},A1 & "thrdstnd"))-1)& ", " & SUBSTITUTE(MID(A1, MIN(FIND({"rd","th","st","nd"},A1 & "thrdstnd"))+2,LEN(A1)),",","")) You can add other suffixes as you need to the formula Then you can format it as you like. 回答2: Nested

SQL date format conversion from INT(yyyymmdd) type to date(mm/dd/yyyy)

混江龙づ霸主 提交于 2019-12-30 06:48:15
问题 I have a table with datekey column values(20120728,20120728...) in format of yyyymmdd as int type, I need to make them into date format of mm/dd/yyyy while writing select statement. 回答1: DECLARE @date int; SET @date = 20131107 SELECT CONVERT(date, CONVERT(varchar(8), @date), 112) 回答2: Please Try This DECLARE @date int; SET @date = 20120728 SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime 来源: https://stackoverflow.com/questions/19829818/sql-date-format

SQL date format conversion from INT(yyyymmdd) type to date(mm/dd/yyyy)

ⅰ亾dé卋堺 提交于 2019-12-30 06:47:06
问题 I have a table with datekey column values(20120728,20120728...) in format of yyyymmdd as int type, I need to make them into date format of mm/dd/yyyy while writing select statement. 回答1: DECLARE @date int; SET @date = 20131107 SELECT CONVERT(date, CONVERT(varchar(8), @date), 112) 回答2: Please Try This DECLARE @date int; SET @date = 20120728 SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime 来源: https://stackoverflow.com/questions/19829818/sql-date-format

Converting unix time into date-time via excel

依然范特西╮ 提交于 2019-12-29 19:26:29
问题 Trying to convert 1504865618099.00 Unix time into a readable date time. I tried this: =(UNIX + ("1/1/1970"-"1/1/1900"+1)*86400) / 86400 But it's not working. 回答1: To convert the epoch(Unix-Time) to regular time like for the below timestamp Ex: 1517577336206 First convert the value with the following function like below =LEFT(A1,10) & "." & RIGHT(A1,3) The output will be like below Ex: 1517577336.206 Now Add the formula like below =(((B1/60)/60)/24)+DATE(1970,1,1) Now format the cell like

How to convert date format in golang?

一曲冷凌霜 提交于 2019-12-29 01:45:11
问题 I would like to convert date format from 2010-01-23 11:44:20 to Jan 23 '10 at 11:44 in golang. I tried few functions from time package but couldn't make it. Could someone help me with this? 回答1: You could use the time package's Parse and Format to convert it to the desired text format. Both take a reference time (2006-01-02 15:04:05) in the format you require as a parameter which makes the format fairly easy to understand. dtstr1 := "2010-01-23 11:44:20" dt,_ := time.Parse("2006-01-02 15:04

Convert one date format into another in PHP

旧巷老猫 提交于 2019-12-25 18:32:26
问题 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 string,