SQL Server: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]

In order to be independent of the language and locale settings, you should use the ISO 8601 YYYYMMDD format – this will work on any SQL Server system with any language and regional setting in effect: SELECT CAST( CAST(year AS VARCHAR(4)) + RIGHT(‘0’ + CAST(month AS VARCHAR(2)), 2) + RIGHT(‘0’ + CAST(day AS VARCHAR(2)), 2) … Read more

How to convert between time zones in PHP using the DateTime class?

What you’re looking for is this: $triggerOn = ’04/01/2013 03:08 PM’; $user_tz = ‘America/Los_Angeles’; echo $triggerOn; // echoes 04/01/2013 03:08 PM $schedule_date = new DateTime($triggerOn, new DateTimeZone($user_tz) ); $schedule_date->setTimeZone(new DateTimeZone(‘UTC’)); $triggerOn = $schedule_date->format(‘Y-m-d H:i:s’); echo $triggerOn; // echoes 2013-04-01 22:08:00

How do I convert a date/time to epoch time (unix time/seconds since 1970) in Perl?

If you’re using the DateTime module, you can call the epoch() method on a DateTime object, since that’s what you think of as unix time. Using DateTimes allows you to convert fairly easily from epoch, to date objects. Alternativly, localtime and gmtime will convert an epoch into an array containing day month and year, and … Read more

Conversion from milliseconds to DateTime format

DateTime in .NET is initialized to 0001-01-01 00:00:00 and then you add your TimeSpan, which seems to be 45 Years. It is common for such (milli)-second time definitions to start at 1970-01-01 00:00:00, so maybe the following gives you the expected result: double ticks = double.Parse(startdatetime); TimeSpan time = TimeSpan.FromMilliseconds(ticks); DateTime startdate = new DateTime(1970, … Read more

How to convert time to ” time ago ” in android

I see mainly three ways: a) built-in options using SimpleDateFormat and DateUtils SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss.SSS’Z'”); sdf.setTimeZone(TimeZone.getTimeZone(“GMT”)); try { long time = sdf.parse(“2016-01-24T16:00:00.000Z”).getTime(); long now = System.currentTimeMillis(); CharSequence ago = DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS); } catch (ParseException e) { e.printStackTrace(); } b) external library ocpsoft/PrettyTime (based on java.util.Date) Here you have to use SimpleDateFormat, too, … Read more