I'm using the following function to get the current timestamp:  $created_timestamp = date("Y-m-d H:i:s");   But how do I get a timestamp for the last day of next month. So for example, if it is the 15th of September to get the 31st of October. Including all the hours, minutes and seconds as well?
1342
I need to get the first and last day of a month in the format YYYY-MM-DD given only the month and year. Is there a good, easy way to do this?
77368
Some issues with timezones in PHP have been in the back of my mind for a while now, and I was wondering if there are better ways to handle it than what I'm currently doing.  All of the issues revolve around reformating database stored dates:  When dealing with a site that has to support multiple timezones (for users), to normalize the timezone offest of stored timestamps I always store it with the server timezone using the CURRENT_TIMESTAMP attribute or the NOW() function.   This way I don't have to consider what timezone was set for PHP when the timestamp was entered (since PHP time functions are timezone aware). For each user, according to his preference I set the timezone somewhere in my bootstrap file using:  date_default_timezone_set($timezone);   When I'm looking to format dates with the php date() function, some form of conversion has to take place since MySQL currently stores timestamp in the format Y-m-d H:i:s. With no regard to timezone, you could simply run:  $date = date($format,strtotime($dbTimestamp));   The problem with this is that date() and strtotime() are both timezone aware functions, meaning that if the PHP timezone is set differently from the server timezone, the timezone offset will apply twice (instead of once as we would like).  To deal with this, I usually retrieve MySQL timestamps using the UNIX_TIMESTAMP() function which is not timezone aware, allowing my to apply date() directly on it - thereby applying the timezone offset only once.  I don't really like this 'hack' as I can no longer retrieve those columns as I normally would, or use * to fetch all columns (sometimes it simplifies queries greatly). Also, sometimes it's simply not an option to use UNIX_TIMESTAMP() (especially when using with open-source packages without much abstraction for query composition).  Another issue is when storing the timestamp, when usage of CURRENT_TIMESTAMP or NOW() is not an option - storing a PHP generated timestamp will store it with the timezone offset which I would like to avoid.  I'm probably missing something really basic here, but so far I haven't been able to come up with a generic solution to handle those issues so I'm forced to treat them case-by-case. Your thoughts are very welcome
101677
I'd really like a user option to show all dates as yyyy-mm-dd HH:mm after the 2 day mark. I find the existing non-standard semi-verbose American Mon DD 'YY style date to be ugly and difficult to parse.  I am not asking for anything complicated here, just a simple user option to show the date and time in the international ISO 8601 format across the board. Since it's already in the tooltip everywhere, it should be a simple change to optionally show it in the page body for those users who want it.  Secondarily, if it's not too difficult, I'd very preferably like to see date &amp; times in my local time, rather than the UTC time as is currently shown used. It seems to make much more sense to me for see a question "asked 2014-02-04 10:19" as being my local time - I don't know what UTC is without using a converter (in this the before-2-days "asked 6 hours ago" is quite good).  (Re-raising this feature-request at the explicit behest of moderator Anna Lear; please don't close as a duplicate).
52755
I need to get the current time but to be in type DateTime. I use:  DateTime now = System.now();   but it returns wrong time. I execute the code in 2017-08-04 00:38:46 AM but it returns     00:38:46:023 USER_DEBUG [138]|DEBUG|now 2017-08-03 21:38:46   How can I get my correct current local time 2017-08-04 00:38:46?  I had even tried with:  DateTime now = DateTime.parse(System.Now().format());   but I still get wrong time.     01:10:09:021 USER_DEBUG [139]|DEBUG|now 2017-08-03 22:10:00   How can I get the correct current local time?
13653
How do I get timestamp from e.g. 22-09-2008?
65208
Is there a common way to get the current time in or with milliseconds?  There is os.time(), but it only provides full seconds.
101488
Alright, quick question.  A server is running in Eastern Time. PHP program needs to make date calculations using Central time.  At the moment, I am putting this line at the very top of my script:  putenv("TZ=US/Central");   Is that the best way to go about that or is there some PHP trick I'm not aware of?  Cheers.
77164
I need a select from table which does not have column that tells when row was inserted, only timestamp column (values like: 0x0000000000530278). Some data was imported to the table yesterday and now I need to find out what exactly was imported :(  Is there a way to do it using only timestamp info?  I found that:   Timestamp is a 8 bytes sequential Hex number, that has nothing to do with neither the date nor the time. To get the current value of timestamp, use: @@DBTS.   Perhaps there is a way to find what was timestamp value around specific time? That would help to form a select. Or maybe there is a well known solution?
36412
I wish to prepend a timestamp to each line of output from a command. For example:  foo bar baz   would become  [2011-12-13 12:20:38] foo [2011-12-13 12:21:32] bar [2011-12-13 12:22:20] baz   ...where the time being prefixed is the time at which the line was printed. How can I achieve this?
25978
Presently the date is showing as mmm dd hh:mm:ss. Is there any way that I can change it to as per my liking. For example : dd mmm, hh:mm:ss.
120364
I am not able to set Current_timestamp as default value. My Mysql version is 5.5.47.  Query is  ALTER TABLE `downloads` ADD `date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ;     While it is working fine on my local DB with mysql V5.6.56.
106085
I want to rename my file to the current timestamp.I know how to get the current timestamp("date +%s") but how can I pipe it to 'mv' command?
4268
Given a specific DateTime value, how do I display relative time, like:   2 hours ago 3 days ago a month ago
80348
The detail view of Thunar shows the modification time as localized date (dd.mm.YYYY for my location), which is fine, but I would like to see the time, too.   And it doesn't show the recently modified files in the same manner, butnew years new years  decorates them as 'yesterday, today, monday' and so on, which is a nice programming etude, but not really useful to me.   Au contraire - it is pretty annoying to have this mixture in the interface. The next version will look into my calender and mark some files 'easter 2007, moms birthday 2002' and 'third monday of last month'. Thank you!   But if ohters prefer it - I'm fine. I just want to know whether I can modify the setting somehow. This is Xubuntu 12.04 LTS, Thunar 1.2.3.
81419
Is it possible to use the =today() function (or something else) to insert the current date but then not update each time the file is opened?  I want to create a numbers template for my invoices. I'd like it to auto fill invoice date and date due then, when I save the document, store the values, not the function.
67969
I have a custom search form that I posts a year + month, such as 2014-04 I would like to get all nodes created that month, when I create the timestmap I use: "SELECT .......         AND changed >= 'strtotime($date)'"  This is the code for form date:  $form['aqar_date'] = array( '#type' =&gt; 'date_select',  '#title' =&gt; t('Date'), '#prefix' =&gt; '&lt;div id="space_replace" class="search-title-date"&gt;   &lt;h2&gt;Node date&lt;/h2&gt;', '#suffix' =&gt; '&lt;/div&gt;',      '#date_format' =&gt; 'Y-m', '#default_value' =&gt; date('Y-m'), '#date_year_range' =&gt; '-4:+0',  );   This is the form submit:  $start_date = strtotime($date); $query = " SELECT `nid` FROM `node` WHERE  `type` = 'custom'  AND `changed` &gt;= '$start_date'";   But I'm not getting, I need a way to specify to only this month period not this month and newer!  Thanks!
117625
I store backups of databases in a directory structure  year/month/day/time/backup_name  an example would be   basics_mini/2012/11/05/012232/RATIONAL.0.db2inst1.NODE0000.20110505004037.001 basics_mini/2012/11/06/012251/RATIONAL.0.db2inst1.NODE0000.20110505003930.001  note that timestamp from the backup file cannot be used. Before the automation testing starts the server time is set to 5.5.2011  So the question is how I can get the latest file if I pass the "base directory" (basics_mini) to some function that I am going to code.  I need to restore the newest database. I do that in php but I wonder if there is a simple shell scripting solution.