unix-timestamp

MySQL convert date string to Unix timestamp

和自甴很熟 提交于 2019-11-26 03:37:56
问题 How do I convert the following format to unix timestamp? Apr 15 2012 12:00AM The format I get from DB seems to have AM at the end. I\'ve tried using the following but it did not work: CONVERT(DATETIME, Sales.SalesDate, 103) AS DTSALESDATE, CONVERT(TIMESTAMP, Sales.SalesDate, 103) AS TSSALESDATE where Sales.SalesDate value is Apr 15 2012 12:00AM 回答1: Try this Query for CONVERT DATETIME to UNIX TIME STAMP SELECT UNIX_TIMESTAMP(STR_TO_DATE('Apr 15 2012 12:00AM', '%M %d %Y %h:%i%p')) This Query

Converting a UNIX Timestamp to Formatted Date String

跟風遠走 提交于 2019-11-26 02:17:02
问题 Using PHP, I want to convert UNIX timestamps to date strings similar to this: 2008-07-17T09:24:17Z How do I convert a timestamp such as 1333699439 to 2008-07-17T09:24:17Z ? 回答1: Try gmdate like this: <?php $timestamp=1333699439; echo gmdate("Y-m-d\TH:i:s\Z", $timestamp); ?> 回答2: use date function date ( string $format [, int $timestamp = time() ] ) Use date('c',time()) as format to convert to ISO 8601 date (added in PHP 5) - 2012-04-06T12:45:47+05:30 use date("Y-m-d\TH:i:s\Z",1333699439) to

Convert unix time stamp to date in java [duplicate]

我们两清 提交于 2019-11-26 02:09:20
问题 This question already has answers here : Unix epoch time to Java Date object (7 answers) Closed 2 years ago . How can I convert minutes from unix time stamp to date and time in java. For example, time stamp 1372339860 correspond to Thu, 27 Jun 2013 13:31:00 GMT . I want to convert 1372339860 to 2013-06-27 13:31:00 GMT . Edit : Actually I want it to be according to US timing GMT-4, so it will be 2013-06-27 09:31:00 . 回答1: You can use SimlpeDateFormat to format your date like this: long

How do you get a timestamp in JavaScript?

▼魔方 西西 提交于 2019-11-26 01:18:40
问题 How can I get a timestamp in JavaScript? Something similar to Unix timestamp, that is, a single number that represents the current time and date. Either as a number or a string. 回答1: Short & Snazzy: + new Date() A unary operator like plus triggers the valueOf method in the Date object and it returns the timestamp (without any alteration). Details: On almost all current browsers you can use Date.now() to get the UTC timestamp in milliseconds ; a notable exception to this is IE8 and earlier

How to get the unix timestamp in C#

醉酒当歌 提交于 2019-11-26 01:05:52
问题 I have had look around stackoverflow, and even looked at some of the suggested questions and none seem to answer, how do you get a unix timestamp in C#? 回答1: You get a unix timestamp in C# by using DateTime.UtcNow and subtracting the epoch time of 1970-01-01. e.g. Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; DateTime.UtcNow can be replaced with any DateTime object that you would like to get the unix timestamp for. There is also a field,

Converting unix timestamp string to readable date

眉间皱痕 提交于 2019-11-25 22:45:32
问题 I have a string representing a unix timestamp (i.e. \"1284101485\") in Python, and I\'d like to convert it to a readable date. When I use time.strftime , I get a TypeError : >>>import time >>>print time.strftime(\"%B %d %Y\", \"1284101485\") Traceback (most recent call last): File \"<stdin>\", line 1, in <module> TypeError: argument must be 9-item sequence, not str 回答1: Use datetime module: from datetime import datetime ts = int("1284101485") # if you encounter a "year is out of range" error