Questions tagged [datetime-conversion]

Use this tag for questions related to the Datetime conversion, i.e. manipulating the Datetime in such a way, that a new, different in format, Datetime is produced.

is used in its general meaning, and is usually used for questions related on how to convert a Datetime object in another, new and with a different format, Datetime object, usually for making two different programming platforms communicate.

For example, your application may produce Datetimes of a specific format, but your Database to accept another Datetime format, different from the one your application is using. In that case, a conversion form the application's format to the Database's format is needed.

316 questions
216
votes
16 answers

How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?

This is a bit of my JS code for which this is needed: var secDiff = Math.abs(Math.round((utc_date-this.premiere_date)/1000)); this.years = this.calculateUnit(secDiff,(86400*365)); this.days =…
Jo Smo
  • 6,923
  • 9
  • 47
  • 67
175
votes
6 answers

Compare DATETIME and DATE ignoring time portion

I have two tables where column [date] is type of DATETIME2(0). I have to compare two records only by theirs Date parts (day+month+year), discarding Time parts (hours+minutes+seconds). How can I do that?
abatishchev
  • 98,240
  • 88
  • 296
  • 433
150
votes
9 answers

How to convert ZonedDateTime to Date?

I am trying to set a server agnostic date time in my database and I believe the best practice to do so is to set a UTC DateTime. My db server is Cassandra and the db driver for Java understands only the Date type. So assuming that in my code I am…
101
votes
8 answers

Convert from days to milliseconds

I want to create a function that will convert the days into milliseconds. The days format is stored as 0.2444, so how to convert this to milliseonds?
maas
  • 1,183
  • 4
  • 10
  • 9
54
votes
5 answers

Convert ZonedDateTime to LocalDateTime at time zone

I have an object of ZonedDateTime that is constructed like this ZonedDateTime z = ZonedDateTime.of(LocalDate.now().atTime(11, 30), ZoneOffset.UTC); How can I convert it to LocalDateTime at time zone of Switzerland? Expected result should be 16…
Vitalii
  • 10,091
  • 18
  • 83
  • 151
46
votes
5 answers

pandas convert from datetime to integer timestamp

Considering a pandas dataframe in python having a column named time of type integer, I can convert it to a datetime format with the following instruction. df['time'] = pandas.to_datetime(df['time'], unit='s') so now the column has entries like:…
roschach
  • 8,390
  • 14
  • 74
  • 124
33
votes
4 answers

Convert DateTime for MySQL using C#

I want to change the DateTime for MySQL in C#. My MySQL database only accept this format 1976-04-09 22:10:00. In C# have a string who have a date value: string str = "12-Apr-1976 22:10"; I want to convert for MySQL then it look like: 1976-04-12…
Steven Spielberg
31
votes
16 answers

How to convert AM/PM timestmap into 24hs format in Python?

I'm trying to convert times from 12 hour times into 24 hour times... Automatic Example times: 06:35 ## Morning 11:35 ## Morning (If m2 is anywhere between 10:00 and 12:00 (morning to mid-day) during the times of 10:00 and 13:00 (1pm) then the m2…
Ryflex
  • 5,559
  • 25
  • 79
  • 148
28
votes
4 answers

LocalDateTime to java.sql.Date in java 8?

How to convert LocalDateTime to java.sql.Date in java-8? My search on internet mostly give me Timestamp related code or LocalDate to java.sql.Date. I'm looking for LocalDateTime to java.sql.Date.
Ajeetkumar
  • 1,271
  • 7
  • 16
  • 34
27
votes
1 answer

Dart - Converting Milliseconds Since Epoch (UNIX timestamp) into human readable time

Is there a good way to parse milliseconds since epoch (ex. 1486252500000 13 digits) formatted time into a human readable format?
Arthur Daniel
  • 331
  • 1
  • 3
  • 7
19
votes
5 answers

Multiply each integer in a flat array by 60

I have an array called $times. It is a list of small numbers (15,14,11,9,3,2). These will be user submitted and are supposed to be minutes. As PHP time works on seconds, I would like to multiply each element of my array by 60. I've been playing…
Sabai
  • 1,579
  • 5
  • 24
  • 40
17
votes
5 answers

Java 8 - Convert LocalDate to OffsetDateTime

I like to know if it is possible to convert in Java 8 from LocalDate to OffsetDateTime. For example assume that I have got this LocalDate: 1992-12-28 Then I would like to have it converted to this OffsetDateTime: 1992-12-28T00:00-03:00 Assume that…
Sandro Rey
  • 2,429
  • 13
  • 36
  • 80
15
votes
6 answers

How to create human readable time stamp?

In my PHP program, I'm using $_SERVER to log the page's date visited: $dateStamp = $_SERVER['REQUEST_TIME']; The result is that the $dateStamp variable contains a Unix timestamp like: 1385615749 What's the simplest way to convert it into a…
user4951
  • 32,206
  • 53
  • 172
  • 282
14
votes
3 answers

Convert UNIX time (INT) to timestamp in BigQuery

I have a column "date_time" in a BigQuery table which contains unix timestamp values like "1569888224". The problem is that these values are integer data types, not timestamp data types, so I do not seem to have an easy way to convert them to human…
12
votes
3 answers

Convert unix timestamp (s) to day of week in C++?

How could I determine the day of the week in California (Pacific Time) based on an arbitrary Unix timestamp (seconds)? I have searched around, but have not found a built-in library for C++. UTC is generally 8 hours ahead of PT, but simply…
John Hoffman
  • 17,857
  • 20
  • 58
  • 81
1
2 3
21 22